Closed WillGibson closed 8 years ago
Hello Will,
this does not answer your question precisely but I've been working on this today.
So far I've got this http://pastebin.com/9kjgmiDm
Check the FROM_SCRATCH variable in that Vagrantfile, maybe you can get some ideas.
I'm also looking for the "after up" scenario. If I will have some news I'll keep you posted
Thanks @damko, that would work apart from the fact that we are using VMware.
I'm trying something in our Puppet manifest...
@WillGibson did you have any luck?
We had to go another route due to deadlines.
In our Vagrantfile...
config.vm.provision :shell, :inline => "cd /vagrant/_migrations && ./migrate_on_first_vagrant_up"
In /vagrant/_migrations/migrate_on_first_vagrant_up...
#!/usr/bin/env bash
migration_done_file="/home/vagrant/.first_build_migration_done"
function check_last_command {
status=$?
if [ $status -ne 0 ]; then
exit $status
fi
return 0
}
if [ ! -e $migration_done_file ]; then
/vagrant/vendor/bin/phinx migrate -c /vagrant/_migrations/phinx.yml
check_last_command
touch $migration_done_file
check_last_command
fi
exit 0
It works well enough.
The built-in provisioner should work for your use case:
Vagrant.configure("2") do |config|
# Your existing Vagrant configuration
...
config.vm.provision "trigger", :option => "value" do |trigger|
trigger.fire do
run "script"
end
end
end
Cheers :smiley:
@emyl Wouldn't that run any time you do vagrant provision?
Maybe this is already possible, but I can't find any documentation to point me in the right direction, but...
Is it possible to hook into the "after up" only when the Vagrant box is created from scratch?