From bd324f9d86a79eb3a7a1a781c82eede8a4a447b8 Mon Sep 17 00:00:00 2001 From: WhatsARanjit Date: Fri, 25 Aug 2017 01:11:35 +0000 Subject: Added to_json function with tests and README --- lib/puppet/functions/to_yaml.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/puppet/functions/to_yaml.rb (limited to 'lib/puppet/functions/to_yaml.rb') diff --git a/lib/puppet/functions/to_yaml.rb b/lib/puppet/functions/to_yaml.rb new file mode 100644 index 0000000..fdd7370 --- /dev/null +++ b/lib/puppet/functions/to_yaml.rb @@ -0,0 +1,21 @@ +# Take a data structure and output it as YAML +# +# @example how to output YAML +# # output yaml to a file +# file { '/tmp/my.yaml': +# ensure => file, +# content => to_yaml($myhash), +# } +# +# +require 'yaml' + +Puppet::Functions.create_function(:to_yaml) do + dispatch :to_yaml do + param 'Any', :data + end + + def to_yaml(data) + data.to_yaml + end +end -- cgit v1.2.3