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]> 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]. > 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/CADHESCUKv0HNLnxkNgAOTd%3DaOzCW0J7irgFX%3DbZdh%3D3v6KbDbw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
