lib/gaptool-client.rb in gaptool-client-0.6.13 vs lib/gaptool-client.rb in gaptool-client-0.6.14

- old
+ new

@@ -38,36 +38,34 @@ :key_data => [$api.ssh(node['role'], node['environment'], node['instance'])['key']], :config => false, :keys_only => true, :paranoid => false ) do |ssh| - stdout_data = "" - stderr_data = "" exit_code = nil exit_signal = nil commands.each do |command| ssh.open_channel do |channel| - channel.exec(command) do |ch, success| + channel.exec(command) do |chx, success| unless success abort "FAILED: couldn't execute command (ssh.channel.exec)" end - channel.on_data do |ch,data| + channel.on_data do |chd,data| puts "#{Rainbow(node['role']).yellow}:#{Rainbow(node['environment']).yellow}:#{Rainbow(node['instance']).yellow}> #{data}" end - channel.on_extended_data do |ch,type,data| + channel.on_extended_data do |che,type,data| puts "#{Rainbow(node['role']).yellow}:#{Rainbow(node['environment']).yellow}:#{Rainbow(node['instance']).red}> #{data}" end - channel.on_request("exit-status") do |ch,data| + channel.on_request("exit-status") do |chs,data| exit_code = data.read_long if exit_code != 0 exit exit_code end end - channel.on_request("exit-signal") do |ch, data| + channel.on_request("exit-signal") do |chg, data| exit_signal = data.read_string end end end end @@ -245,20 +243,27 @@ nodes = [$api.getonenode(instance)] else nodes = $api.getenvroles(role, environment) end nodes.peach do |node| + if node['chef_runlist'].nil? + runlist = ['recipe[main]'] + elsif node['chef_runlist'].is_a? Array + runlist = node['chef_runlist'] + else + runlist = eval(node['chef_runlist']) + end json = { 'this_server' => "#{role}-#{environment}-#{node['instance']}", 'role' => role, 'environment' => environment, 'app_user' => node['appuser'], - 'run_list' => node['chef_runlist'].nil? ? ['recipe[main]'] : eval(node['chef_runlist']), + 'run_list' => runlist, 'hostname' => node['hostname'], 'instance' => node['instance'], 'zone' => node['zone'], 'itype' => node['itype'], - 'apps' => eval(node['apps']), + 'apps' => eval(node['apps'] || '[]'), }.merge(attrs) git="git fetch --all; git reset --hard origin/`git rev-parse --abbrev-ref HEAD`" unless chef_branch.nil? json['chefbranch'] = chef_branch