Class: VagrantBolt::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-bolt/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, machine, boltconfig = nil) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
12
13
# File 'lib/vagrant-bolt/runner.rb', line 8

def initialize(env, machine, boltconfig = nil)
  @env = env
  @machine = machine
  @boltconfig = boltconfig.nil? ? VagrantBolt::Config::Bolt.new : boltconfig
  @inventory_path = VagrantBolt::Util::Bolt.inventory_file(@env)
end

Instance Method Details

#run(command, name, **args) ⇒ Object

Run a bolt task or plan

Examples:

run('task', 'facts', ["machinename"])

Parameters:

  • command (Symbol, String)

    The command of bolt to run; task or plan

  • name (String)

    The name of the bolt task or plan to run

  • args (Hash)

    A optional hash of bolt config overrides. No merging will be done with the overrides



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vagrant-bolt/runner.rb', line 20

def run(command, name, **args)
  @boltconfig = setup_overrides(command, name, **args)
  # Don't run anything if there are targets to run it on
  # TODO: Gate this in a more efficient manner. It is possible to run plans without a target list.
  return if @boltconfig.target_list.nil?

  @inventory_path = VagrantBolt::Util::Bolt.update_inventory_file(@env)
  validate
  command = VagrantBolt::Util::Bolt.generate_bolt_command(@boltconfig, @inventory_path)
  VagrantBolt::Util::Machine.run_command(command, @machine.ui)
end