假设我有一个值数组
["node1.example.org", "node2.example.org"]我想用facter来传递它,并在puppet中使用它,如下:
host {
$nodes:
...
}我该怎么做呢?
发布于 2014-04-09 22:15:56
Facter 1.x不能将结构化数据作为事实值传递。所有事实都将被强制转换为字符串格式。这对于数组来说尤其不幸,因为这些数组的元素将在没有连接标记的情况下连接起来。
建议让事实返回一个逗号分隔的列表,例如,用do代替返回Array result
result * ","在清单中,将其重新转换为数组
$nodes_array = split($nodes, ',')
host { $nodes_array: }请参阅Puppet function reference和Ruby的Array methods。
Facter 2确实支持Boolean、Hash和Array事实,但这可能还不是很容易获得。
https://stackoverflow.com/questions/22959505
复制相似问题