How to run commands when starting up a Vagrant box
Some of us at Culture Foundry run vagrant instances for development. This virtual machine lets you manage different environments or work in a unix environment if that is your wish. It’s heavier weight than a solution like docker, but depending on your infrastructure and/or sysadmin skills, may be more intuitive.
Our development depends on a database, which may be PostgreSQL or MySQL. However, for the version of Ubuntu that we were running, MySQL didn’t start up, at least the version we were using. After some searching, the easiest solution to implement was just to put the startup script in the Vagrant file. This looks like:
config.vm.provision "shell", inline: "sudo service mysql start", run: "always"
You can use this syntax to run any command you want run once and only once as your Vagrant machine boots up. More on the shell provisioner here.