I want to run a cookbook_file resource only if the current environment is "dev". How can this be expressed?
The documentation suggests this:
In a recipe, a code block like this would be useful:
qa_nodes = search(:node,"chef_environment:QA") qa_nodes.each do |qa_node| # Do useful specific to qa nodes only end
But I'm not sure that's what I want - the fact it's a loop seems wrong.
only_if { node.chef_environment == "dev" }. Confirmed. – Steve Bennett Aug 16 '12 at 00:39if "#{node.chef_environment}" == "dev"– spuder Aug 20 '15 at 16:31