I’ve struggled immenslely trying to get a Vagrant provision that would successfully set up Postgres so that I could jump into a rails project. I don’t know why it was so hard, but it was. People insisted on Puppet, Chef and Ansible. I don’t understand why generic shell scripting isn’t more popular for the Vagrantfile. None of these solutions resulted in a database that I could hook up to with rails.
When I first looked at the official Postgres vagrant page I assumed it was having me download an already-set-up Vagrant image, already cooking, intending to be a self-contained db server. I didn’t want that, I wanted to add postgres to my own home-grown image that I’ve built up over time from a base Ubuntu box.
Well, after I finally took the time to actually look at it, I realized the official pgsql vagrant setup is just doing a basic shell provision on top of the ubuntu/trusty64 image (The same one I based off)!
After a few basic modifications to the config file to make Postgres more Vagrant-friendly by default, everything is working really nicely. You can find the rails-vagrant setup I’ve put together here. Being new to Rails, Vagrant, and psql, I’m not actually sure that this is the best way to set this up, but it’s working great for me!