Ansible playbooks and roles for deploying Rails applications to EC2
MIT License
Ansible roles and playbooks for deploying a Rails application to EC2. This was a learning experiment so keep it in mind if you intend to use it.
The system will configure:
It also includes a playbook for deploying to different environments using Ansible (without using Capistrano or any other third-party system).
It includes 2 environments:
production
: With an EC2-based inventory.production-vagrant
: Which runs on virtual machines orchestrated by Vagrant. It is meant for experimenting with the production environment locally, which is much more suitable for development time.It would be pretty trivial to add other environments such as staging. Just copy an existing environment and tweak it.
Notice there are some files that are soft links to avoid duplication. For example: environments/production/group_vars/all/00-common.yml
environments/common.yml
ansible-galaxy install -r requirements.yml
You can configure basic properties such as your app name and git repo in environments/common.yml
.
You should use Ansible Vault to encrypt the sensitive data such as passwords and keys in:
environments/common-vault.yml
db/vault.yml
The system assumes that you have a file in ~/ vault_password.txt
containing your password. That way, it won't ask you for it in every operation.
Edit environments/production-vagrant/group_vars/all/vars.yml
to configure your EC2 nodes. Example: the type and number of instances you want to use.
To provision EC2 instances:
ansible-playbook -i environments/production provision.yml
Provisioning instances will create the instances in EC2 and configure them with all the artifacts they need.
If you only want to launch the configurations of instances:
ansible-playbook -i environments/production configure.yml
To deploy to a given environment:
ansible-playbook -i environments/production deploy.yml
Vagrant up will create the virtual machines and configure them:
cd environments/production-vagrant
vagrant up
You can launch the configuration only with:
ansible-playbook -i environments/production-vagrant configure.yml
Or, alternatively, with vagrant provision
Then you could deploy normally with:
ansible-playbook -i environments/production-vagrant deploy.yml
ansible-playbook -i environments/production services.yml