From 00ce442de80f3a8865783cd0966578425d81b714 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 18 Oct 2013 18:27:01 -0300 Subject: [PATCH] core: Allow hooking before and after provisioners --- lib/vagrant/action/builtin/provision.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/vagrant/action/builtin/provision.rb b/lib/vagrant/action/builtin/provision.rb index 99ed32f54..3a79c7f99 100644 --- a/lib/vagrant/action/builtin/provision.rb +++ b/lib/vagrant/action/builtin/provision.rb @@ -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