]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Add ability to extract keys from nodeinfo
authorStephen Gran <steve@lobefin.net>
Sat, 23 May 2009 13:38:15 +0000 (14:38 +0100)
committerStephen Gran <steve@lobefin.net>
Sat, 23 May 2009 13:38:15 +0000 (14:38 +0100)
Signed-off-by: Stephen Gran <steve@lobefin.net>
files/etc/puppet/lib/puppet/parser/functions/extractnodeinfo.rb [new file with mode: 0644]

diff --git a/files/etc/puppet/lib/puppet/parser/functions/extractnodeinfo.rb b/files/etc/puppet/lib/puppet/parser/functions/extractnodeinfo.rb
new file mode 100644 (file)
index 0000000..d12386f
--- /dev/null
@@ -0,0 +1,13 @@
+module Puppet::Parser::Functions
+  newfunction(:extractnodeinfo, :type => :rvalue) do |args|
+
+    nodeinfo = args[0]
+    key      = args[1]
+
+    if nodeinfo.has_key?(key)
+      return nodeinfo[key]
+    else
+      return "false"
+    end
+  end
+end