【问题标题】:Chef recipe fails at compiling cookbook厨师食谱在编译食谱时失败
【发布时间】: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


【解决方案1】:

阅读https://coderanger.net/two-pass/ 了解如何强制在编译时运行。

也就是说,请不要这样做。通过 Chef 本身分发数据包密钥违背了安全模型的全部要点,而且毫无意义。

【讨论】:

  • 好文章! only_if 从编译阶段绕过这个。谢谢,确实不是一个好主意,我只是在尝试 POC。如果您有一些文章或想法如何正确使用加密数据包,那将非常有用。
猜你喜欢
  • 2014-01-03
  • 1970-01-01
  • 1970-01-01
  • 2019-01-29
  • 1970-01-01
  • 2021-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多