我正在写一个厨师食谱,在ec2实例上安装Splunk。我只想在实例的初始设置上安装Splunk。配方不需要再次运行。
我正在使用通知仅在满足条件时执行后续代码块:
#install splunk
dpkg_package 'splunkforwarder' do
source '/tmp/splunkforwarder.deb'
action :nothing
notifies :run, 'execute[configure-splunk]', :immediately
end
这是通知的块
commands = ['command1', 'command2', 'etc']
commands.each do |i|
execute "configure-splunk" do
command i
action :nothing
end
end
问题是当调用'configure-splunk'时,它似乎只运行列表中的最后一个命令而不是循环遍历所有命令。我在这里错过了什么?
这是正确的,当您有多个具有相同名称+类型对的资源时,在查找该名称时只有最后一个可用。
你可能想要的是:
execute "configure-splunk" do
command commands.join(' && ')
action :nothing
end