Dead Simple provisioning for Ruby on Rails & MySQL with Vagrant and Centos 6.6

Dead Simple provisioning for Ruby on Rails & MySQL with Vagrant and Centos 6.6

One of the hardest things about getting started with Vagrant is the time it takes develop a good provisioning system for the virtual machine. Many people reach to Chef or Ansible too quickly and become overwhelmed by complexity. It was recently suggested that one start with a simple provision script.

Here is a provision script that I used recently to config a Centos 6.6 vm.

Here is the Vagrantfile:

You will notice in the Vagrantfile that we forward the MySQL port 3306 to 13306. I still want to connect to the MySQL database on the vm from my local machine so to this I update the my local database.yml.

I can now run commands like bundle exec rake db:migrate on my local machine. Since it can modify files, this is preferred. I run the server as well my rspecs on the vagrant box. During development, I have an rsync command running as follows to sync my file changes down to the local machine.

vagrant rsync-auto

Next time, I can show how this same setup can be done with PostgreSQL.