core: Allow hooking before and after provisioners

This commit is contained in:
Fabio Rehm 2013-10-18 18:27:01 -03:00
parent a92e03cf4c
commit 00ce442de8
1 changed files with 20 additions and 0 deletions

View File

@ -68,10 +68,30 @@ 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
action_runner.run(callable, :action_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