summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/parseyaml.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions/parseyaml.rb')
-rw-r--r--lib/puppet/parser/functions/parseyaml.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb
new file mode 100644
index 00000000..53d54faf
--- /dev/null
+++ b/lib/puppet/parser/functions/parseyaml.rb
@@ -0,0 +1,24 @@
+#
+# parseyaml.rb
+#
+
+module Puppet::Parser::Functions
+ newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
+This function accepts YAML as a string and converts it into the correct
+Puppet structure.
+ EOS
+ ) do |arguments|
+
+ if (arguments.size != 1) then
+ raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+
+ "given #{arguments.size} for 1")
+ end
+
+ require 'yaml'
+
+ YAML::load(arguments[0])
+
+ end
+end
+
+# vim: set ts=2 sw=2 et :