Class: VagrantPlugins::Ignition::Action::SetupIgnition

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-ignition/action/setup_ignition.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SetupIgnition



7
8
9
# File 'lib/vagrant-ignition/action/setup_ignition.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
30
31
32
33
# File 'lib/vagrant-ignition/action/setup_ignition.rb', line 11

def call(env)
  @env = env

  if env[:machine].config.ignition.enabled == false
    @app.call(env)
    return
  end

  config_path = env[:machine].config.ignition.path
  config_vmdk = env[:machine].config.ignition.config_vmdk
  config_img = env[:machine].config.ignition.config_img

  hostname = env[:machine].config.ignition.hostname
  ip = env[:machine].config.ignition.ip

  vmdk_gen(config_path, config_vmdk, config_img, hostname, ip, env)

  env[:machine].ui.info "Configuring Ignition Config Drive"
  env[:machine].provider.driver.execute("storageattach", "#{env[:machine].id}", "--storagectl", "IDE Controller", "--device", "0", "--port", "1", "--type", "hdd", "--medium", "#{config_vmdk}")

  # Continue through the middleware chain
  @app.call(env)
end