Skip to content

Instantly share code, notes, and snippets.

@zipkid
Created June 22, 2012 13:56
Show Gist options
  • Save zipkid/2972872 to your computer and use it in GitHub Desktop.
Save zipkid/2972872 to your computer and use it in GitHub Desktop.
/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
resources:
package:
jdk:
ensure: absent
=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