在第二部分中,您现在可以将数组/散列作为事实。
例如:
os => { "name"=>"CentOS", "family"=>"RedHat", "release"=>{ "major"=>"7", "minor"=>"0", "full"=>"7.0.1406" } }
什么是从清单访问os=>release=>major的格式?
比如像这样:
notify { $::os[release][major] : }
请注意,您需要将选项stringify_facts设置为false才能使其工作(默认情况下,使用Puppet 3.7.1编写:true)。
应该可以像往常一样访问它的散列数据types: https : //docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#indexing-1
$myhash = {os => { "name"=>"CentOS", "family"=>"RedHat", "release"=>{ "major"=>"7", "minor"=>"0", "full"=>"7.0.1406" } } } notice( $myhash[os][release][major] )
您可以通过使用散列来访问清单中的事实,如下所示:
notify { $::os['release']['major']: }
例:
# puppet apply -e 'notify { $::os['release']['major']: }' Notice: Compiled catalog for mon.adriatic.local in environment production in 0.04 seconds Notice: 6 Notice: /Stage[main]/Main/Notify[6]/message: defined 'message' as '6' Notice: Applied catalog in 0.28 seconds