summaryrefslogtreecommitdiff
path: root/lib/puppet/functions/to_yaml.rb
blob: fdd7370450de2004770ece926ed12486510496a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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