我只想在当前环境为“dev”的情况下运行cookbook_file资源。 这怎么能expression出来?
文档build议这样做:
在一个配方中,像这样的代码块将是有用的:
qa_nodes = search(:node,"chef_environment:QA") qa_nodes.each do |qa_node| # Do useful specific to qa nodes only end
但我不知道这就是我想要的 – 事实上这是一个循环似乎是错误的。
查看节点上的chef_environment Ruby属性(不是常规Chef属性):
if node.chef_environment == "dev" # stuff end
另一个优雅的方式
if ['production','development'].include? node.chef_environment #do something here end