[英]Puppet - Using node scope variables in Hiera config
我正在嘗試在我的hiera.yaml配置中使用節點范圍變量,這顯然應該相對簡單,但它只是不適合我Lol
使用像這樣的hiera.yaml:
---
:backends:
- yaml
:yaml:
:datadir: /etc/puppet/hieradata
:hierarchy:
- nodes/%{::hostname}
- builds/%{build}
- common
我的site.pp是這樣的:
hiera_include('classes')
node 'mynode' {
$build = special
}
和其他yaml文件,
common.yaml:
---
classes:
- first_class
- second_class
建立/ special.yaml:
---
classes:
- third_class
我希望'mynode'在刷新木偶代理時獲得'third_class',但它沒有,並且沒有錯誤。
運行hiera命令給了我正確的(我認為)輸出:
$ hiera classes
["first_class","second_class"]
$ hiera classes build=special
["third_class"]
有沒有明顯的事情我在這里做錯了?
%{::hostname}
有效。 如果我添加nodes / mynode.yaml,則會選擇該配置。
經過幾個小時的搔癢,報告了puppetlabs上的文檔錯誤(我現在已經關閉了Lol)並且幾乎完全放棄了這個想法,只是創建了一個自定義的事實,我發現它是一個如此簡單的修復......它是有道理的。 ..
基本上我需要做的就是改變我的site.pp:
hiera_include('classes')
node 'mynode' {
$build = special
}
至:
node 'mynode' {
$build = special
hiera_include('classes')
}
它現在很有意義,因為正如你所看到的,我需要在設置node-scope變量后調用hiera_include
。
(盡管我剛剛發現),如果你在hiera_include('classes')
有hiera_include('classes')
並且你在多個yaml文件中設置一個類參數,那么它只會使用common.yaml中設置的參數。 。
可能是最煩人的事情,就是通過我所有的試驗和錯誤,我在某些時候把hiera_include
放在節點聲明中,我只是沒有把它放在變量Lol之后
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.