A Vagrant box for Rails development, provisioned with Ansible.
- Install Ansible
- Run
sudo ansible-galaxy install rvm_io.rvm1-ruby
- Copy the following into your Rails app folder: (if this is a new Rails app that hasn't been created yet, copy them into the project folder you want to use.)
ansible/
Vagrantfile
- Edit
ansible/playbook.yml
to comment out any installations you don't need - Edit
ansible/config.yml
to configure versions and DB setup info - From within your Rails app folder, run
vagrant up
- From within your Rails app folder, run
vagrant ssh
. This will connect you to the Vagrant box. - From within the Vagrant box, run
cd /vagrant
- If this is a new Rails app that hasn't been created yet, run
rails new .
. This will create a new Rails app in that folder - Set up your app to use the database connection provided. Either:
-
Install the
dotenv
gem and update yourdatabase.yml
with the following entries:yml development: host: <%= ENV['DB_HOST'] %> database: <%= ENV['DB_NAME'] %> username: <%= ENV['DB_USERNAME'] %> password: <%= ENV['DB_PASSWORD'] %> test: host: <%= ENV['DB_HOST'] %> database: <%= ENV['DB_NAME'] %>_test username: <%= ENV['DB_USERNAME'] %> password: <%= ENV['DB_PASSWORD'] %>
-
Or, hard-code your
database.yml
file to use the same config asansible/config.yml
(not recommended)
-
- Run any of your normal Rails setup commands, like
bundle install
andbin/rake db:migrate
- Run
bin/rails server -b 0.0.0.0
Then your app will be accessible at http://localhost:3000
Any service that runs in the virtual machine that you want access to on your host (i.e. in a web browser) needs to bind to 0.0.0.0, not localhost. The command to do this is different for different systems. For example:
bin/rails server -b 0.0.0.0
mailcatcher --ip 0.0.0.0
MIT. See License file for more info.