我想从facter <prop>
文件内容中注入一些值。
它适用于$fqdn
因为facter fqdn
返回字符串。
node default {
file {'/tmp/README.md':
ensure => file,
content => $fqdn, # $(facter fqdn)
owner => 'root',
}
}
但是,它不适用于哈希对象 ( facter os
):
node default {
file {'/tmp/README.md':
ensure => file,
content => $os, # $(facter os) !! DOES NOT WORK
owner => 'root',
}
}
并在运行时收到此错误消息puppet agent -t
:
错误:无法应用目录:文件[/tmp/README.md]上的参数内容失败:值{“architecture”=>“x86_64”,“family”=>“RedHat”,“hardware”=>”的Munging失败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”}}:没有将哈希隐式转换为字符串(文件:/etc/puppetlabs/code/environments/production/manifests/site.pp,行:2)
如何将哈希转换为pp
文件内的字符串?