Code Monkey home page Code Monkey logo

ansible-rails-toolkit's Introduction

Ansible Rails Toolkit

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:

  • A Postgres instance
  • An instance with Nginx acting as a load balancer for the web servers
  • A number of web servers with puma
  • Monit for monitoring the different servers
  • A Jenkins instance

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

Usage

Install dependencies

ansible-galaxy install -r requirements.yml

Configure app variables

You can configure basic properties such as your app name and git repo in environments/common.yml.

Edit and encrypt sensitive data (vault files)

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.

Configure your EC2 servers

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.

Provision instances

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.

Configure instances

If you only want to launch the configurations of instances:

 ansible-playbook -i environments/production configure.yml

Deploy

To deploy to a given environment:

ansible-playbook -i environments/production deploy.yml

Working with Vagrant

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

Provision Jenkins instance

ansible-playbook -i environments/production services.yml

Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.