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 :Provision, "vagrant/action/builtin/provision"
|
||||
autoload :ProvisionerCleanup, "vagrant/action/builtin/provisioner_cleanup"
|
||||
autoload :ProvisionerRun, "vagrant/action/builtin/provisioner_run"
|
||||
autoload :SetHostname, "vagrant/action/builtin/set_hostname"
|
||||
autoload :SSHExec, "vagrant/action/builtin/ssh_exec"
|
||||
autoload :SSHRun, "vagrant/action/builtin/ssh_run"
|
||||
|
|
|
@ -68,19 +68,10 @@ module Vagrant
|
|||
# subclass and implement custom behavior if they'd like around
|
||||
# this step.
|
||||
def run_provisioner(env, name, p)
|
||||
hook(:before_provisioner)
|
||||
|
||||
env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning",
|
||||
:provisioner => name))
|
||||
|
||||
p.provision
|
||||
|
||||
hook(:after_provisioner)
|
||||
end
|
||||
|
||||
def hook(name)
|
||||
@logger.info("Running hook: #{name}")
|
||||
callable = Action::Builder.new
|
||||
callable = Builder.new.tap { |b| b.use ProvisionerRun, p }
|
||||
action_runner.run(callable, :action_name => name)
|
||||
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