Class: Vagrant::Action::Builtin::HasProvisioner

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/action/builtin/has_provisioner.rb

Overview

This middleware is used with Call to test if this machine has available provisioners

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ HasProvisioner

Returns a new instance of HasProvisioner.


7
8
9
10
# File 'lib/vagrant/action/builtin/has_provisioner.rb', line 7

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant::action::builtin::has_provisioner")
end

Instance Method Details

#call(env) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vagrant/action/builtin/has_provisioner.rb', line 12

def call(env)
  machine = env[:machine]

  if machine.provider.capability?(:has_communicator)
    has_communicator = machine.provider.capability(:has_communicator)
  else
    has_communicator = true
  end

  env[:skip] = []
  if !has_communicator
    machine.config.vm.provisioners.each do |p|
      if p.communicator_required
        env[:skip].push(p)
        @logger.info("Skipping running provisioner #{p.name || 'no name'}, type: #{p.type}")
        p.run = :never
      end
    end
  end
  @app.call(env)
end