aboutsummaryrefslogtreecommitdiff
path: root/lib/puppet
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-01-29 23:18:46 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-01-29 23:18:46 -0200
commitde12cc5eefc51924b9dd0f89712076ecdb81a52e (patch)
treef14f5ed0428c67b364a0af0c9b9997cc8ef9ccad /lib/puppet
parentda1a58d5ee1623a7cc17045b9e2953c1c9f449ef (diff)
downloadpuppet-nodo-de12cc5eefc51924b9dd0f89712076ecdb81a52e.tar.gz
puppet-nodo-de12cc5eefc51924b9dd0f89712076ecdb81a52e.tar.bz2
Adding hiera_resources function
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/functions/hiera_resources.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/hiera_resources.rb b/lib/puppet/parser/functions/hiera_resources.rb
new file mode 100644
index 0000000..1299314
--- /dev/null
+++ b/lib/puppet/parser/functions/hiera_resources.rb
@@ -0,0 +1,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