CHEF 中的條件依賴

CHEF 中的條件依賴

我有一個複雜的軟體堆棧,我用兩個配方來管理。

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()或檢查運行清單。

相關內容