https://gist.github.com/1389228Instead of shelling out to knife each time, could I just require 'Chef', initialize a few values, and work from there?I might be able to figure it out by looking thru the chef source code, but I am lazy, so I thought I would ask first ;)#!/usr/bin/env ruby
servers = %x[ knife search node "name:*econ*" -i].splitservers = 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]"]endif 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]"]endendif 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
Archive powered by MHonArc 2.6.16.