Last active
November 10, 2015 10:43
-
-
Save kam1kaze/5e3622b0574b35bab483 to your computer and use it in GitHub Desktop.
chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add item to runlist | |
export item='recipe[job::redis]' | |
knife exec -E 'nodes.find("chef_environment:staging") {|n| puts n.run_list << ENV["item"] unless n.run_list.include?(ENV["item"]); n.save }' | |
# Delete item from runlist | |
export item='recipe[job::redis]' | |
knife exec -E 'nodes.transform("chef_environment:staging") {|n| puts n.run_list.remove(ENV["item"]); n.save }' | |
# Replace item in runlist | |
export item_from='recipe[base::nginx]' | |
export item_to='role[frontend]' | |
knife exec -E 'nodes.find("chef_environment:staging") {|n| next unless n.run_list.include?(ENV["item_from"]); list = n.run_list.map{|x| x == ENV["item_from"] ? ENV["item_to"] : x }; puts n.run_list(list); n.save}' | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment