Puppet Function: loadanyyaml
- Defined in:
- lib/puppet/parser/functions/loadanyyaml.rb
- Function type:
- Ruby 3.x API
Overview
Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type.
For example:
$myhash = loadanyyaml('/etc/puppet/data/myhash.yaml')
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/puppet/parser/functions/loadanyyaml.rb', line 3 newfunction(:loadanyyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type. For example: $myhash = loadanyyaml('/etc/puppet/data/myhash.yaml') ENDHEREDOC args.delete_if { |filename| not File.exist? filename } if args.length == 0 raise Puppet::ParseError, ("loadanyyaml(): No files to load") end YAML.load_file(args[0]) end |