厨师食谱在编辑食谱时失败

时间:2018-02-16 11:35:57

标签: chef

我想加密我的所有主厨data_bags并在/ etc / chef / secret_key中的客户端VM上设置解密密钥,因此在chef-client运行时,它将使用此密钥解密数据包。为此,我在配方中有以下资源:

# 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'))

现在我的问题是我如何优先考虑先设置cookbook_file。当然,我想从一位厨师 - 客户那里做到这一点,而不是分开食谱。

1 个答案:

答案 0 :(得分:1)

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

那就是说,请不要这样做。通过Chef本身分发数据包密钥会破坏安全模型的整个点,并且毫无意义。

相关问题