I want to inject some values from facter <prop>
into a file content.
It works with $fqdn
since facter fqdn
returns string.
node default {
file {'/tmp/README.md':
ensure => file,
content => $fqdn, # $(facter fqdn)
owner => 'root',
}
}
However, it does not work with hash object (facter os
):
node default {
file {'/tmp/README.md':
ensure => file,
content => $os, # $(facter os) !! DOES NOT WORK
owner => 'root',
}
}
And getting this error message when running puppet agent -t
:
Error: Failed to apply catalog: Parameter content failed on File[/tmp/README.md]: Munging failed for value {"architecture"=>"x86_64", "family"=>"RedHat", "hardware"=>"x86_64", "name"=>"CentOS", "release"=>{"full"=>"7.4.1708", "major"=>"7", "minor"=>"4"}, "selinux"=>{"config_mode"=>"enforcing", "config_policy"=>"targeted", "current_mode"=>"enforcing", "enabled"=>true, "enforced"=>true, "policy_version"=>"28"}} in class content: no implicit conversion of Hash into String (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 2)
How to convert the hash to string inside the pp
file?