Created
June 22, 2012 13:56
-
-
Save zipkid/2972872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/create_resources.rb:1: warning: multiple values for a block parameter (2 for 1) | |
from /etc/puppet-modules/custom/lib/puppet/parser/functions/hiera_resources.rb:38 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources: | |
package: | |
jdk: | |
ensure: absent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
http://yo61.com/assigning-resources-to-nodes-with-hiera-in-puppet.html | |
define apache::website::instance( | |
$ListenIP, | |
$ServerAlias = [], | |
$config = '' | |
) { | |
# clever code goes here to instantiate the apache vhost | |
} | |
node default { | |
hiera_resources('resources') | |
} | |
Now, to create the resource as in the previous example, add this to the hiera config: | |
resources: | |
apache::website::instance: | |
'www.example.com': | |
ListenIP: '1.2.3.4' | |
ServerAlias: | |
- 'example.com' | |
- 'foo.example.com' | |
config: |- | |
DocumentRoot /var/www/sites/example | |
<Directory /var/www/sites/example/> | |
AllowOverride None | |
Options +Indexes | |
</Directory> | |
=end | |
Puppet::Parser::Functions.newfunction(:hiera_resources, :type => :statement) do |args| | |
raise Puppet::Error, "hiera_resources requires 1 argument; got #{args.length}" if args.length != 1 | |
apps = function_hiera_hash(args[0], {}) | |
apps.each do |res_type, resources| | |
function_create_resources(res_type, resources) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment