如何根據節點json檔案跳過食譜

如何根據節點json檔案跳過食譜

我有一本這樣的食譜。

if node['httpd'] == "nginx"

  package "nginx" do
    action :install
  end

  # a lot more stuff

end

但我不想在if聲明中包含所有設定。有沒有辦法在廚師中這樣寫?

next if node['httpd'] != "nginx"

package "nginx" do
  action :install
end

# a lot more stuff

如果node['httpd']不是"nginx",我想去看下一本食譜。

答案1

您可以使用return跳過對食譜其餘部分的評估,例如:

return if node['httpd'] != 'nginx'

# ...

相關內容