Puppet
如何使用源儲存庫中的 Hiera 數據?
我有一個無主的 Puppet 設置,我想簡單地添加資訊,例如基於
$::osfamily
可移植性的包名稱。似乎 Hiera 是為這類事情而設計的,但我不知道如何在不修改. 基本上,每篇文件似乎都假設我想在使用不同的儲存庫時進行修改或手動修改。還是我完全誤解了 Hiera?/etc``/etc/puppetlabs/code/hiera.yaml``/etc/puppetlabs/puppet/puppet.conf
如有必要,我可以將 puppet.conf 添加到儲存庫並在每次執行時引用它
puppet apply
,但是我將如何將目前目錄引用為根目錄?hiera_config
是的,您可以將 hiera 數據與無主設置一起使用。只需使用 hiera confiuration 指定 –hiera_config 即可指定在何處查找 hiera 數據。
例子:
nkts@trololo:/tmp/puppet$ puppet apply -t --modulepath=./modules/ --hiera_config=./hiera.conf manifests/a.pp Notice: Compiled catalog for trololo.lan in environment production in 0.31 seconds Info: Applying configuration version '1449108414' Notice: test: bar Notice: /Stage[main]/A/Notify[test: bar]/message: defined 'message' as 'test: bar' Notice: Applied catalog in 0.02 seconds nkts@trololo:/tmp/puppet$ cat hiera.conf --- :backends: yaml :yaml: :datadir: /tmp/puppet/data :hierarchy: common :logger: console nkts@trololo:/tmp/puppet$ cat data/common.yaml a::foo: bar nkts@trololo:/tmp/puppet$ cat manifests/a.pp class { "a": } nkts@trololo:/tmp/puppet$ cat modules/a/manifests/init.pp class a ( $foo = "default msg" ){ notify { "test: $foo": } } nkts@trololo:/tmp/puppet$ rm data/common.yaml nkts@trololo:/tmp/puppet$ puppet apply -t --modulepath=./modules/ --hiera_config=./hiera.conf manifests/a.pp Notice: Compiled catalog for trololo.lan in environment production in 0.32 seconds Info: Applying configuration version '1449108454' Notice: test: default msg Notice: /Stage[main]/A/Notify[test: default msg]/message: defined 'message' as 'test: default msg' Notice: Applied catalog in 0.02 seconds nkts@trololo:/tmp/puppet$