Hi Brian, Thanks for your reply!
> The trick is that the Provision action does not totally function in an obvious way :) I can attest to that :) > This might be more obvious if you run vagrant with the --debug flag. Ok, thanks, I'll try that out to try to understand. > I assume you are writing this for a Vagrant plugin? Yes. Thanks for the pointer to Action Hooks - machine_action_provision, "called after all provisioners have executed", was one I considered. For right now I've resorted to adding a Provisioner to the plugin as I seem to be able to call that where I want within the provisioning steps. The "machine" and "config" parameters provided to the provisioner aren't quite equivalent to the "env" hash given to the Action, so I ended up duplicating some of the code from the Action and passing needed info pulled from the "machine" and "config" inputs ... On Friday, 18 January 2019 16:11:16 UTC-5, Brian Cain wrote: > > Hey there, > > Your understanding of the middleware class is correct! Your action is > likely technically running > after the builtin Provision action (I assume Provision in this case is the > action coming from core Vagrant). > The trick is that the Provision action does not totally function in an > obvious way :) This might be more > obvious if you run vagrant with the --debug flag. > > If you look closely at the builtin Provision action > <https://github.com/hashicorp/vagrant/blob/master/lib/vagrant/action/builtin/provision.rb#L80>, > > when it runs it initially only sets up the provisioner prior to the vm > booting. So if you were running Vagrant without the debug flag, the UI > output might make it seem like your custom action > is running before the Provision action step. But what's actually happening > is the provisioner action sets up the provisioner > to be run later, and then the middleware goes on and executes your custom > action class and anything else on the stack. > > I assume you are writing this for a Vagrant plugin? If you're writing your > own plugin, you can make your custom > action class run after the provision step (in the way you intended to) > with Action Hooks: > https://www.vagrantup.com/docs/plugins/action-hooks.html > > Hope this clears things up, thanks! > > On Fri, Jan 18, 2019 at 12:29 PM Rob Ots <[email protected] <javascript:>> > wrote: > >> I'm new to Vagrant and don't fully understand the middleware pattern, but >> I have a middleware action - a class MyAction with an initialize(app) and a >> call(env) method - that I'd like to run at a specific point in the >> provisioning process. >> >> The following runs the action, but it runs it right at the beginning of >> the vagrant provision command, not when I want. >> >> def self.action_provision >> Vagrant::Action::Builder.new.tap do |b| >> b.use Provision >> b.use MyAction >> end >> end >> >> Is there a way to run that action at a specific point in the provisioning >> process? >> >> -- >> This mailing list is governed under the HashiCorp Community Guidelines - >> https://www.hashicorp.com/community-guidelines.html. Behavior in >> violation of those guidelines may result in your removal from this mailing >> list. >> >> GitHub Issues: https://github.com/mitchellh/vagrant/issues >> IRC: #vagrant on Freenode >> --- >> You received this message because you are subscribed to the Google Groups >> "Vagrant" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/vagrant-up/247ff4af-b0f1-4bc6-9add-b6399d4e2ff9%40googlegroups.com >> >> <https://groups.google.com/d/msgid/vagrant-up/247ff4af-b0f1-4bc6-9add-b6399d4e2ff9%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > Brian Cain > -- This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list. GitHub Issues: https://github.com/mitchellh/vagrant/issues IRC: #vagrant on Freenode --- You received this message because you are subscribed to the Google Groups "Vagrant" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/f48efff6-cc42-4ac3-9184-17eb324d0663%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
