Puppet Function: to_yaml

Defined in:
modules/stdlib/lib/puppet/functions/to_yaml.rb
Function type:
Ruby 4.x API

Overview

to_yaml(Any $data, Optional[Hash] $options)String

Examples:

How to output YAML

# output yaml to a file
  file { '/tmp/my.yaml':
    ensure  => file,
    content => to_yaml($myhash),
  }

Use options control the output format

file { '/tmp/my.yaml':
  ensure  => file,
  content => to_yaml($myhash, {indentation: 4})
}

Parameters:

  • data (Any)
  • options (Optional[Hash])

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'modules/stdlib/lib/puppet/functions/to_yaml.rb', line 18

Puppet::Functions.create_function(:to_yaml) do
  # @param data
  # @param options
  #
  # @return [String]
  dispatch :to_yaml do
    param 'Any', :data
    optional_param 'Hash', :options
  end

  def to_yaml(data, options = {})
    data.to_yaml(options)
  end
end