Created
November 23, 2011 17:06
-
-
Save bryanwb/1389228 to your computer and use it in GitHub Desktop.
loads missing roles for a set of nodes
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
#!/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