Question

Using Vagrant, is it possible to run my provisioning Ansible script just when vagrant up creates the virtual machine? I wan to provision just when the import sequence is run. I have a very slow step that imports the database. It isn't idempotent and I'd like it to run just the first time.

I can make a script using vagrant status and vagrant up --no-provision, but I believe there should be a more straightforward way.

I also can just run Ansible after the first vagrant up, but then I won't be able to brag to my friends that I create my server from scratch running just one command :-)

Was it helpful?

Solution

I think you are using a version older than 1.3.0;-)

Since Vagrant 1.3.0, vagrant up only run provisioning by default the first time it runs (after the import). Subsequent reload or up will need to explicitly specify the --provision flag, for example vagrant up --provision or just vagrant provision.

See the full changelog

The change => vagrant up will now only run provisioning by default the first time it is run. Subsequent reload or up will need to explicitly specify the --provision flag to provision. [GH-1776]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top