我正在使用下面的代码,以便在下载gem文件后chef_gem可以正常工作。但是,即使我将compile_time指定为true,也会在收敛后首先调用chef_gem。
remote_file "/home/scripts/#{File.basename(node['EBSMount']['open4_url'])}" do
source node['EBSMount']['open4_url']
end
chef_gem 'open4' do
action :install
source "/home/scripts/#{File.basename(node['EBSMount']['open4_url'])}"
clear_sources true
compile_time true
end
答案 0 :(得分:0)
[增订]
尝试修改compile_time
,如下所示 -
chef_gem 'open4' do
#...
compile_time true if Chef::Resource::ChefGem.instance_methods(false).include?(:compile_time)
end
您可以使用关键字“通知”来链接执行步骤。最佳做法是将依赖资源块操作设置为“无”,并使用notifies关键字来调用操作。
remote_file "/home/scripts/#{File.basename(node['EBSMount']['open4_url'])}" do
source node['EBSMount']['open4_url']
notifies :install, 'chef_gem[open4]', :immediately
end
chef_gem 'open4' do
action :nothing
source "/home/scripts/#{File.basename(node['EBSMount']['open4_url'])}"
clear_sources true
compile_time true
end
以下是关于“Notifies Resource”
的厨师文档