to_yaml.rb 372 B

123456789101112131415161718192021
  1. # Take a data structure and output it as YAML
  2. #
  3. # @example how to output YAML
  4. # # output yaml to a file
  5. # file { '/tmp/my.yaml':
  6. # ensure => file,
  7. # content => to_yaml($myhash),
  8. # }
  9. #
  10. #
  11. require 'yaml'
  12. Puppet::Functions.create_function(:to_yaml) do
  13. dispatch :to_yaml do
  14. param 'Any', :data
  15. end
  16. def to_yaml(data)
  17. data.to_yaml
  18. end
  19. end