Merge pull request #2405 from fgrehm/2044-provisioner-hooking

core: support hooking around provisioners runs
This commit is contained in:
Mitchell Hashimoto 2013-11-24 21:07:53 -08:00
commit d6fb083507
3 changed files with 37 additions and 1 deletions

View File

@ -20,6 +20,7 @@ module Vagrant
autoload :Lock, "vagrant/action/builtin/lock" autoload :Lock, "vagrant/action/builtin/lock"
autoload :Provision, "vagrant/action/builtin/provision" autoload :Provision, "vagrant/action/builtin/provision"
autoload :ProvisionerCleanup, "vagrant/action/builtin/provisioner_cleanup" autoload :ProvisionerCleanup, "vagrant/action/builtin/provisioner_cleanup"
autoload :ProvisionerRun, "vagrant/action/builtin/provisioner_run"
autoload :SetHostname, "vagrant/action/builtin/set_hostname" autoload :SetHostname, "vagrant/action/builtin/set_hostname"
autoload :SSHExec, "vagrant/action/builtin/ssh_exec" autoload :SSHExec, "vagrant/action/builtin/ssh_exec"
autoload :SSHRun, "vagrant/action/builtin/ssh_run" autoload :SSHRun, "vagrant/action/builtin/ssh_run"

View File

@ -78,7 +78,21 @@ module Vagrant
env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning", env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning",
:provisioner => name)) :provisioner => name))
p.provision callable = Builder.new.tap { |b| b.use ProvisionerRun, p }
action_runner.run(callable,
:action_name => :provisioner_run,
:provider_name => name
)
end
def action_runner
@action_runner ||= Action::Runner.new do
{
:env => @env[:env],
:machine => @env[:machine],
:ui => @env[:ui]
}
end
end end
end end
end end

View File

@ -0,0 +1,21 @@
require "log4r"
module Vagrant
module Action
module Builtin
# This action is basically a wrapper on top of provisioner runs that
# enable plugins to hook around the provisioning itself
class ProvisionerRun
def initialize(app, env, provisioner)
@app = app
@provisioner = provisioner
end
def call(env)
@app.call(env)
@provisioner.provision
end
end
end
end
end