Class: VagrantBolt::ConfigBuilder::Triggers

Inherits:
Config
  • Object
show all
Defined in:
lib/vagrant-bolt/config_builder/triggers.rb

Instance Attribute Summary collapse

Attributes inherited from Config

#args, #bolt_exe, #boltdir, #command, #connect_timeout, #debug, #excludes, #facts, #features, #host_key_check, #machine_alias, #machine_name, #modulepath, #name, #node_list, #nodes, #noop, #params, #password, #port, #private_key, #project, #run_as, #ssl, #ssl_verify, #sudo_password, #target_list, #targets, #tmpdir, #user, #vars, #verbose

Instance Method Summary collapse

Instance Attribute Details

#trigger_commandsArray<Symbol>

Returns The commands that the trigger should run on. E.g. [:up, :provision].

Returns:

  • (Array<Symbol>)

    The commands that the trigger should run on. E.g. [:up, :provision]



13
# File 'lib/vagrant-bolt/config_builder/triggers.rb', line 13

def_model_attribute :trigger_commands

#trigger_typeSymbol

Returns A symbol containing the the trigger action. Valid values are :before and :after.

Returns:

  • (Symbol)

    A symbol containing the the trigger action. Valid values are :before and :after



9
# File 'lib/vagrant-bolt/config_builder/triggers.rb', line 9

def_model_attribute :trigger_type

Instance Method Details

#to_procObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant-bolt/config_builder/triggers.rb', line 15

def to_proc
  options = @attrs.dup
  trigger_type = options.delete(:trigger_type)
  trigger_commands = options.delete(:trigger_commands)
  command = options.delete(:command)
  name = options.delete(:name)
  proc do |config|
    config.trigger.send(trigger_type, trigger_commands) do |trigger|
      trigger.ruby do |env, machine|
        VagrantBolt.send(command, name, env, machine, **options)
      end
    end
  end
end