[英]Overwrite Puppet Class Variables in Manifest
我目前正在使用 hiera 為 Puppet forge Gitlab 模塊設置所有類參數。
cat hieradata/nodes/example.yaml
---
gitlab::backup_cron_enable: true
gitlab::gitlab_rails:
backup_keep_time: 604800
backup_path: /opt/gitlab_backup
gitlab_default_can_create_group: false
initial_root_password: foobar
...
cat site/profiles/manifests/gitlab.rb
class profile::gitlab {
include gitlab
}
此代碼按預期工作,但我想修改日志輸出和報告中的密碼值。 我嘗試使用 hiera_options 來轉換敏感值,但 Puppet 仍然顯示未編輯的值。
cat hieradata/nodes/example.yaml
---
lookup_options:
gitlab::gitlab_rails::initial_root_password:
convert_to: "Sensitive"
gitlab::backup_cron_enable: true
gitlab::gitlab_rails:
backup_keep_time: 604800
backup_path: /opt/gitlab_backup
gitlab_default_can_create_group: false
initial_root_password: foobar
...
在使用 hiera 定義類參數時,編輯所有敏感值的最佳方法是什么?
您需要將密碼作為單獨的密鑰才能使自動轉換生效。 查找的鍵綁定到散列,並且不可能使用lookup_options
來處理散列中的單個值( lookup_options
是整個散列)。
您可以通過使用別名並將明文密碼綁定到單獨的密鑰來使單個值Sensitive
- 如下所示:
cat hieradata/nodes/example.yaml
---
lookup_options:
gitlab::gitlab_rails::initial_root_password:
convert_to: "Sensitive"
gitlab::backup_cron_enable: true
gitlab::gitlab_rails:
backup_keep_time: 604800
backup_path: /opt/gitlab_backup
gitlab_default_can_create_group: false
initial_root_password: '%{alias("gitlab::gitlab_rails::initial_root_password")}'
gitlab::gitlab_rails::initial_root_password: 'foobar'
...
通過這種方法,您還可以使用 EYAML 或其他一些安全的層次結構后端以加密形式存儲密碼。 這樣的后端可能已經返回包裹在Sensitive
解密值 - 例如,這是由 Vault 后端完成的。
但是,即使您通過了第一個障礙,結果也取決於gitlab
模塊如何處理現在包含Sensitive
值的散列。 如果它只是傳遞initial_root_password
的值可能會起作用,但是如果它正在對該值執行任何操作(例如檢查它是否為空字符串),它可能會失敗。 如果您不走運,它似乎可以工作,但您最終可能會得到密碼“已編輯”:-)。 如果它不起作用,請聯系模塊的維護者,並要求他們支持將密碼作為Sensitive
值而不是字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.