Re: Adding middleware from inside the Vagrantfile

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Adding middleware from inside the Vagrantfile

Rob Yurkowski
Jakub,

Thank you for your post. It saved me quite a bit of time this morning, especially point #2!

Rob

On Wednesday, 19 December 2012 05:21:02 UTC-5, Jakub Krajewski wrote:
On Tuesday, December 18, 2012 2:36:37 AM UTC+1, Folken Laƫneck wrote:
Hi Jakub,

Hello Folken,
 
You have to use Vagrant.actions instead of Vagrant::Action to alter stacks. The first refers to the hash of middleware stacks used by Vagrant while the second is the Ruby module where middlewares and stack builder are defined.
[...]

You are absolutely right, thank you. It works using Vagrant.actions, all inside Vagrantifle. More to say that I had been just building my Ruby knowledge since I started to write own Vagrant file, so it was heavily lacking then. :)

If someone else will encounter this post and want to write custom middleware then it is also nice to remember that:
1) According to what I read at this list :start and :up actions are different (up is for scenario where VM is created, while start starts already created one) - this may save you few hours.
2) Actions like Provisioning or settings hostname pass the @app.call() quite early (even before any provisioning or setting actual machine hostname takes place), so if one wants to execute action somewhere after machine boots it is better to write own simple provisioner (at least it was for me :) and do the work there.

Best regards,
Jakub Krajewski

--