
我有一個複雜的軟體堆棧,我用兩個配方來管理。
recipe[stack::foo]
recipe[stack::bar]
foo
安裝在每台伺服器上,而bar
僅安裝在一部分伺服器上。bar
取決於文件和服務foo
。
食譜[堆疊::foo]
file 'fooFile' do
source 'somewhere'
notifies :restart, service[barService] #bar needs to be restart first, if it is present
notifies :restart, service[fooService]
end
service 'fooService' do
action :start
end
食譜[堆疊::欄]
file 'barFile' do
source 'somewhere'
end
service 'barService' do
action :start
end
是否可以建立條件依賴關係,以便如果bar
節點上存在配方,它將重新啟動它。如果不是,它將跳過它。
我正在嘗試這樣的事情
file 'fooFile' do
source 'somewhere'
notifies :restart, service[barService] if exists? "service[barService]"
notifies :restart, service[fooService]
end
答案1
在 IRC 中回答,使用者 spuder 告知不鼓勵重複詢問。
tl;dr 使用resources()
或檢查運行清單。