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

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

In my last blog post, I covered Dead Simple provisioning for Ruby on Rails & MySQL with Vagrant and Centos 6.6

Let’s run through a similar config, only this time using PostgreSQL 9.4

First, let’s look at the provision script. Because PostgreSQL handles connections and permissions via config files, we have to do some ugly sed commands to modify those file. The resulting script is here:

Our Vagrantfile changes only slightly. We now map the Postgres Port instead of the MySQL port.

Finally, since we are mapping the Postgres port 5432 on the vm to port 15432 on the host, we’ll want to update the database.yml on the host to connect to Postgres via port 15432.

Again, during development, I run an rsync command running as follows to sync my file changes down to the local machine.

vagrant rsync-auto