Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created November 23, 2011 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwb/1389228 to your computer and use it in GitHub Desktop.
Save bryanwb/1389228 to your computer and use it in GitHub Desktop.
loads missing roles for a set of nodes
#!/usr/bin/env ruby
servers = %x[ knife search node "name:*econ*" -i].split
servers = servers.slice(3, servers.length)
servers.each do |s|
run_list_str = %[knife node show #{s} -r -f json]
run_list = JSON.parse(s_run_list)
if not run_list.include? "role[base]"
%x[knife node run_list add #{s} "role[base]"]
end
if not run_list.include? "role[int0]" or not run_list.include? "role[ext0]"
if s =~ /^ext.*$/
%x[knife node run_list add #{s} "role[ext0]"]
else
%x[knife node run_list add #{s} "role[int0]"]
end
end
if not run_list.include? "role[econ]"
%x[knife node run_list add #{s} "role[econ]"]
end
%x[ knife ssh name:${s} "chef-client" -x root -i .chef/identity ]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment