这里是我的食谱代码,没有这样的文件或目录 - 文件未找到错误的厨师
include_recipe 'aws'
require 'aws-sdk'
client = Aws::S3::Client.new(region: 'us-east-1')
bucket = client.get_object(bucket:'chefconfig', key: 'encrypted_data_bag_secret')
# Read content to variable
file_content = bucket.body.read
# Log output (optional)
Chef::Log.info(file_content)
# Write content to file
file '/etc/chef/encrypted_data_bag_secret' do
owner 'root'
group 'root'
mode '0755'
content file_content
action :create
end
password_secret = Chef::EncryptedDataBagItem.load_secret('/etc/chef/encrypted_data_bag_secret')
docker_password_data_bag_item = Chef::EncryptedDataBagItem.load('passwords', 'docker_server_master_password', password_secret)
docker_service 'default' do
action [:create, :start]
end
docker_registry 'https://index.docker.io/v1/' do
username node['docker']['username']
password docker_password_data_bag_item['password']
email node['docker']['email']
end
我想file
资源将创造/etc/chef/encrypted_data_bag_secret
第一,将可用于Chef::EncryptedDataBagItem.load_secret
但是当我运行这个食谱我开始越来越以下错误消息。
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/appservers/recipes/default.rb
================================================================================
Errno::ENOENT
-------------
No such file or directory - file not found '/etc/chef/encrypted_data_bag_secret'
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/appservers/recipes/docker.rb:29:in `from_file'
/var/chef/cache/cookbooks/appservers/recipes/default.rb:9:in `from_file'
由于我在引导节点时添加了这本菜谱,所以我不知道如何在引导过程中提供秘密文件。
的可能的复制[请解释编译时间与在厨师的食谱运行时间?(http://stackoverflow.com/questions/25980820/please-explain-compile-time-vs-run-时间在厨师食谱) – Tensibai
重复不是相同的问题有答案解释你为什么以这种行为结束,主要是Tejay答案。 – Tensibai
谢谢你指出正确的方向。我解决了这个问题。为了将来的参考和其他我在这里添加解决方案。 – Balkrishna