emyl / vagrant-triggers

Allow the definition of arbitrary scripts that will run on the host before and/or after Vagrant commands.
MIT License
546 stars 35 forks source link

No trigger for taking action between "halt" and "up" stages of "reload" #87

Closed mmic-bjohnson closed 6 years ago

mmic-bjohnson commented 7 years ago

When issuing the vagrant reload command, there appears to be no means by which to take action between the time the VM is halted and the time the VM is started.

According to the Vagrant manual, vagrant reload is:

The equivalent of running a halt followed by an up.

Yet, if I configure the following trigger, it does not fire during the vagrant reload cycle:

config.trigger.after [:halt] do
# ...
end

Perhaps this is intentional, but how, then, should one go about taking action between the halt and up stages of a reload?

jamiejackson commented 6 years ago

I just ran into this today. I figured that since is a reload is just a shorthand for vagrant halt && vagrant up, that config.trigger.before :halt would be triggered before the halt phase, but it seems that the reload action is overlooked by the vagrant-triggers plugin.

jamiejackson commented 6 years ago

That gave me an idea; unfortunately, it doesn't work, because the the child vagrant processes clash with the parent:

  config.trigger.instead_of :reload, :option => "value" do
    run "vagrant halt"
    run "vagrant up"
  end