aboutsummaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/hiera_resources.rb
blob: 12993147b77350e86854f8647242ebaa29148389 (plain)
1
2
3
4
5
6
7
8
9
# Thanks to http://yo61.com/assigning-resources-to-nodes-with-hiera-in-puppet.html
module 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
    res_name = args[0][0]
    apps = function_hiera_hash([res_name, {}])
    apps.each { | res_type, res_params | function_create_resources([res_type, res_params]) }
  end
end