class Gaptool::ChefrunCommand
Public Instance Methods
execute()
click to toggle source
# File lib/gaptool_client/commands.rb, line 259 def execute attrs = Gaptool::Helpers.split_attrs(attribute_list) nodes = Gaptool::API.query_nodes(hidden: hidden? ? true : nil, role: role, instance: instance, environment: environment) nodes = nodes.map { |x| x.merge('attrs' => attrs) } pre_hook = proc do |node| upload!(StringIO.new(node['attrs'].merge( 'run_list' => node['chef_runlist'] || ['role[base]'] ).to_json), '/tmp/chef.json') end command = 'sudo gtrunchef -j /tmp/chef.json' command = "#{command} -W" if whyrun? command = "#{command} -B #{chef_branch}" if chef_branch command = "#{command} -v" if verbose? res = Gaptool::SSH.exec( nodes, [command], pre_hooks: [pre_hook], serial: serial?, continue_on_errors: continue_on_errors?, batch_size: batch_size ) exit res end