Class: Vagrant::Action::VM::Provision
- Inherits:
-
Object
- Object
- Vagrant::Action::VM::Provision
- Defined in:
- lib/vagrant/action/vm/provision.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #enabled_provisioners ⇒ Object
-
#initialize(app, env) ⇒ Provision
constructor
A new instance of Provision.
Constructor Details
#initialize(app, env) ⇒ Provision
Returns a new instance of Provision.
7 8 9 10 11 12 |
# File 'lib/vagrant/action/vm/provision.rb', line 7 def initialize(app, env) @logger = Log4r::Logger.new("vagrant::action::vm::provision") @app = app env["provision.enabled"] = true if !env.has_key?("provision.enabled") end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant/action/vm/provision.rb', line 14 def call(env) @env = env provisioners = nil # We set this here so that even if this value is changed in the future, # it stays constant to what we expect here in this moment. enabled = env["provision.enabled"] # Instantiate and prepare the provisioners. Preparation must happen here # so that shared folders and such can properly take effect. provisioners = enabled_provisioners provisioners.map { |p| p.prepare } @app.call(env) if enabled # Take prepared provisioners and run the provisioning provisioners.each do |instance| @env[:ui].info I18n.t("vagrant.actions.vm.provision.beginning", :provisioner => instance.class) instance.provision! end end end |
#enabled_provisioners ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vagrant/action/vm/provision.rb', line 39 def enabled_provisioners enabled = [] @env[:vm].config.vm.provisioners.each do |provisioner| if @env["provision.types"] # If we've specified types of provisioners to enable, then we # only use those provisioners, and skip any that we haven't # specified. if !@env["provision.types"].include?(provisioner.shortcut.to_s) @logger.debug("Skipping provisioner: #{provisioner.shortcut}") next end end enabled << provisioner.provisioner.new(@env, provisioner.config) end # Return the enable provisioners enabled end |