我有一本這樣的食譜。
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'
# ...