]> gitweb.fluxo.info Git - puppet-nodo.git/commitdiff
Adding hiera_resources function
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 30 Jan 2013 01:18:46 +0000 (23:18 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 30 Jan 2013 01:18:46 +0000 (23:18 -0200)
lib/puppet/parser/functions/hiera_resources.rb [new file with mode: 0644]

diff --git a/lib/puppet/parser/functions/hiera_resources.rb b/lib/puppet/parser/functions/hiera_resources.rb
new file mode 100644 (file)
index 0000000..1299314
--- /dev/null
@@ -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