【发布时间】:2018-02-17 03:09:52
【问题描述】:
我想加密我所有的厨师数据包并在 /etc/chef/secret_key 中的客户端虚拟机上设置解密密钥,因此在厨师客户端运行时它将使用此密钥解密数据包。为此,我在配方中有以下资源:
# Put the secret key in /etc/chef
cookbook_file '/etc/chef/rd_seceret_key' do
source 'rd_seceret_key'
action :create
end
# Get the credentials from the databag for the current environment
credentials = data_bag_item('pinpoint', node.chef_environment.downcase, IO.read('/etc/chef/rd_seceret_key'))
....
现在在编译时,它会尝试解决 IO.read('/etc/chef/rd_seceret_key') 问题,当然它还不存在,直到厨师客户端从文件中设置它,就像上面配方中设置的那样。
Errno::ENOENT
-------------
No such file or directory @ rb_sysopen - /etc/chef/rd_seceret_key
98>> credentials = data_bag_item('pinpoint', node.chef_environment.downcase, IO.read('/etc/chef/rd_seceret_key'))
现在我的问题是我如何才能优先设置这个菜谱文件。当然,我想从一个不分离食谱的厨师客户那里做到这一点。
【问题讨论】:
-
你可以使用惰性评估,或者以某种方式将食谱一分为二吗?
-
我不知道什么是惰性评估,是的,拆分菜谱很好,但我想打一次厨师客户。
-
现在我知道什么是惰性求值了,但我认为它不会有帮助,因为我们必须在编译时解决 IO.read('/etc/chef/rd_seceret_key'))。
-
给我 5 分钟试试 :)
标签: chef-infra