Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hooking around provisioners runs #2405

Merged
merged 3 commits into from
Nov 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/vagrant/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Builtin
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"
Expand Down
16 changes: 15 additions & 1 deletion lib/vagrant/action/builtin/provision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,21 @@ def run_provisioner(env, name, p)
env[:ui].info(I18n.t("vagrant.actions.vm.provision.beginning",
: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
Expand Down
21 changes: 21 additions & 0 deletions lib/vagrant/action/builtin/provisioner_run.rb
Original file line number Diff line number Diff line change
@@ -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