core: Improve provisioner hooking by introducing a new builtin action for wrapping provisioner runs
This commit is contained in:
parent
00ce442de8
commit
2debce9dd9
|
@ -21,6 +21,7 @@ module Vagrant
|
||||||
autoload :NFS, "vagrant/action/builtin/nfs"
|
autoload :NFS, "vagrant/action/builtin/nfs"
|
||||||
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"
|
||||||
|
|
|
@ -68,19 +68,10 @@ module Vagrant
|
||||||
# subclass and implement custom behavior if they'd like around
|
# subclass and implement custom behavior if they'd like around
|
||||||
# this step.
|
# this step.
|
||||||
def run_provisioner(env, name, p)
|
def run_provisioner(env, name, p)
|
||||||
hook(:before_provisioner)
|
|
||||||
|
|
||||||
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 }
|
||||||
|
|
||||||
hook(:after_provisioner)
|
|
||||||
end
|
|
||||||
|
|
||||||
def hook(name)
|
|
||||||
@logger.info("Running hook: #{name}")
|
|
||||||
callable = Action::Builder.new
|
|
||||||
action_runner.run(callable, :action_name => name)
|
action_runner.run(callable, :action_name => name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue