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

Conversation

Projects
None yet
2 participants
@fgrehm
Collaborator

fgrehm commented Oct 21, 2013

This PR implements GH-2044 and although I wasn't able to spike on changing vagrant-cachier code to remove the monkey patches we have in place, I wanted to open this up for discussion / code review as I was able to spot 2 other use cases for it :)

Apart from using it on vagrant-cachier, I want to use this feature to finally support fgrehm/vagrant-notify#5 and another use case would be a plugin that keeps track of the time taken on each provisioner run and reports back to the user, something like vagrant-aws's TimedProvision but targeting multiple providers

To try this out, you can use the following Vagrantfile using this branch:

class Action
  def initialize(app, env)
    @app = app
  end

  def call(env)
    puts 'before'
    puts "name: #{env[:provider_name]}"
    @app.call env
    puts 'after'
  end
end

class Plugin < Vagrant.plugin('2')
  name 'testing'
  action_hook 'hook-name', :provisioner_run do |hook|
    hook.before Vagrant::Action::Builtin::ProvisionerRun, Action
  end
end

Vagrant.configure("2") do |config|
  config.vm.box = "some-box"
  config.vm.provision :shell, inline: 'echo hello'
  config.vm.provision :shell, inline: 'echo hello 2'
end
@mitchellh

This comment has been minimized.

Show comment
Hide comment
@mitchellh

mitchellh Nov 25, 2013

Member

This is a great idea. I'm going to modify it slightly but merge this. I'll CC You on the modification, and might just blow your mind.

Member

mitchellh commented Nov 25, 2013

This is a great idea. I'm going to modify it slightly but merge this. I'll CC You on the modification, and might just blow your mind.

mitchellh added a commit that referenced this pull request Nov 25, 2013

Merge pull request #2405 from fgrehm/2044-provisioner-hooking
core: support hooking around provisioners runs

@mitchellh mitchellh merged commit d6fb083 into hashicorp:master Nov 25, 2013

1 check passed

default The Travis CI build passed
Details

@fgrehm fgrehm deleted the fgrehm:2044-provisioner-hooking branch Nov 25, 2013

@fgrehm fgrehm referenced this pull request Dec 3, 2013

Merged

Fix hook with methods #2569

@fgrehm fgrehm referenced this pull request Mar 13, 2014

Closed

vagrant-cachier supprt #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment