Module: KnifeNodeContextExec

Defined in:
lib/knife-node-context-exec/runner.rb,
lib/chef/knife/context_exec.rb,
lib/knife-node-context-exec/version.rb

Overview

Runs commands over a set of nodes

Defined Under Namespace

Classes: ContextExec, NodeRunner

Constant Summary collapse

VERSION =
'1.1.5'.freeze

Class Method Summary collapse

Class Method Details

.run(nodes, working_directory, template_filename, script_filename, command, filter_regex, parallel, clean) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/knife-node-context-exec/runner.rb', line 50

def self.run(nodes, working_directory, template_filename, script_filename, command, filter_regex, parallel, clean)
  FileUtils.makedirs(working_directory)
  temporary_directory = Dir.mktmpdir('x', working_directory)
  nodes = nodes.map do |node|
    node = KnifeNodeContextExec::NodeRunner.new(node, temporary_directory,
                                                template_filename, script_filename, command).run do |line|
      puts line if line =~ /#{filter_regex}/
    end
    node.wait unless parallel
    node
  end
  nodes.each(&:wait)
  nodes.each do |node|
    puts
    puts "===== FULL OUTPUT - #{node.node.name} ======================"
    node.output.each { |line| puts line }
  end
  FileUtils.remove_dir(working_directory) if clean
end