Class: VagrantPlugins::StartCloud::Action::ConfigureProvisioners

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-startcloud/action/configure_provisioners.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ConfigureProvisioners

Returns a new instance of ConfigureProvisioners.



7
8
9
# File 'lib/vagrant-startcloud/action/configure_provisioners.rb', line 7

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-startcloud/action/configure_provisioners.rb', line 11

def call(env)
  machine = env[:machine]
  config = machine.config.startcloud
  provisioning = config.provisioning

  if provisioning && !provisioning.empty?
    env[:ui].info(I18n.t('vagrant_startcloud.configuring.provisioners'))

    begin
      configure_shell_provisioner(machine, provisioning['shell']) if provisioning['shell']&.dig('enabled')
      configure_ansible_provisioner(machine, provisioning['ansible']) if provisioning['ansible']&.dig('enabled')
      configure_docker_provisioner(machine, provisioning['docker']) if provisioning['docker']&.dig('enabled')
    rescue StandardError => e
      raise Errors::ProvisionerConfigurationFailed, error: e.message
    end
  end

  @app.call(env)
end