• Stars
    star
    187
  • Rank 205,297 (Top 5 %)
  • Language
    Python
  • Created over 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of playbooks for getting your rails stack up and running fast!

Ansible-Rails

Rails ansible is a collection of playbooks to bootstrap a full rails stack, complete with Postgres, Redis, Sidekiq, Nginx and HAProxy on Centos 7 targeting Digital Ocean as a host.

The playbooks have 4 primary roles.

  • App Tier (Rails App + Nginx)
  • Services Tier (Postgres / Redis / Memcached)
  • Worker Tier (Sidekiq)
  • Loadbalancer Tier (HAProxy)

In addtional to these 4 tiers there is a pretty extensive core / common role that all tiers/roles include.

Goals of the playbooks are:

  • Create a solid foundation for hosting complex rails applications on CentOS 7.
  • Autoconfigures its own firewall rules, loadbalancer configuration, postgres access, and app environment based on inventory.
  • Build current stable ruby from source, its easy to do and package maintainers seem to have a problem getting this right and keeping things current.
  • Build nginx with phusion passenger.
  • Host rails configuration as environment variables
  • Ensure rails logs are properly rotated
  • Keep a decent ammount of security through very limited firewall exposure
  • Use systemd for services
  • Limit sudo access for webapp user to only service management
  • Automatically provision public-key authentication
  • Provision required servers via DigitalOcean api.

Getting Started

  • Install ansible
  • Review configurations
    • digitalocean.ini
    • provisioning/do_creds.yml
    • group_vars/staging.yml
    • group_vars/production.yml
    • roles/common/templates/app.env.j2
  • Configure SSH private / public keys
    • ~/.ssh/app_private_key.pem
    • roles/common/files/public_key
    • roles/common/myapp.github.pem
    • roles/common/myapp.github.pem.pub
  • Define your required architecture per environment
    • provisioning/requirements/staging.yml
    • provisioning/requirements/produciton.yml

Spin up your instances

Once you've added you Digital Ocean api keys to the required files.

Note: You should be using v1 api keys.

You can go ahead and start your staging environment servers by running the following playbook command.

ansible-playbook -i local provisioning/stack.yml --extra-vars "myapp_env=staging"

If you rolled with the defaults you will have 1 server for each role.

Provision your staging environment

Now is the point where we run our main playbooks to setup the boxes.

ansible-playbook -i dohosts myapp.yml --extra-vars="myapp_env=staging"

With any luck at this point all the software and services for your stack should be running.

Deploy your rails application

We wont go into a ton of detail about how to deploy a rails app. At memms.io we use Capistrano v3, so i've included a few tricks in extra/capistrano/deploy.rb Basically the hacks here are to load our dohosts from ansible and use our dynamic inventory to do our cap deploy. Also one of neat things we do is make sure the app.env variables are loaded for each cap command.

Rinse, wash, repeat

Deploying your staging environment should be as easy as changing myapp_env=production in the ansible-playbook commands.

Troubleshooting / Known-Issues

A few python packages may be missing for some of the local tasks. The dohosts script requires the request package. This can be installed with pip install requests.

To run the digital ocean provisioning scripts you may need the digital ocean python library. pip install dopy

Mac OSX users should install ansible with brew. brew install ansible

Get Help

You can find me in the #ansible room on irc.freenode.net

Contributing

Any issues / problems / feedback should be filed as github issues.

Pull-Requests Welcomed!

Sponsored by

  • memms.io - Memories made easy. No signups, no logins, no fuss, just memms.
  • kohactive.com - Web / Mobile Development Studio

Made with Love by

More Repositories

1

capistrano-slack

Deprecated: Capistrano slack integration, Use Slackistrano with Capistrano 3.
Ruby
70
star
2

ember-cli-chrome

A small and growing toolkit to build chrome extensions with EmberJS
JavaScript
62
star
3

cordova-statusTap

Capture tap events on the status bar.
Objective-C
53
star
4

PhoneGap-ios-PhoneDialer

A plugin for ios phone gap to launch the dialer programatically in ios >= 5
Objective-C
45
star
5

struct-tv

A Live Streaming Site in EmberJS and Pheonix
JavaScript
21
star
6

devise_account_expireable

devise_account_expireable
Ruby
15
star
7

Sencha2-PullToRefresh

A plugin / list extension to add Pull to refresh to Sencha Touch 2.0-pr1
JavaScript
14
star
8

middleman-emblem

Ruby
10
star
9

mes

A scaffolding tool for EmberJS / Middleman / Emblem (SLIM for Handlebars) / Bootstrap
Ruby
9
star
10

buildpack-caddy

Heroku buildpack for caddy
Shell
8
star
11

heroku-znc-example

An example app for running znc on heroku
7
star
12

znc-buildpak

Shell
7
star
13

ember-chrome-demo

A sample chrome extension with Ember-CLI
JavaScript
6
star
14

aboie

Ruby
6
star
15

node-obj-watch

Watches an object for changes and fires an event for notification
CoffeeScript
4
star
16

ios-lightbox

An iOS implementation of a basic lightbox for images.
Objective-C
3
star
17

EmberTwitterApp

A client side EmberJS app that demonstrates client side OAuth and a reverse proxy.
JavaScript
3
star
18

mediocre

A media library built with s3, and carrierwave to make asset uploads easy for static blogs and sites.
Ruby
3
star
19

dotfiles

My dot files
Ruby
2
star
20

envelope-printer

Print an envelope from a web api!
Ruby
2
star
21

EmberWebsocketDemo

A demo app of ember using websockets
JavaScript
2
star
22

gimbal-node

Scanning for gimbal beacons with node / Scanner that works with office_spaces
JavaScript
2
star
23

kohTimePicker

A Time Picker widget for jQuery.
JavaScript
2
star
24

pumpkinpi

RaspberryPi lighting and sound automation
JavaScript
2
star
25

ember-cli-standalone

Build a standalone js file for the environment. Incase you aren't using the hosted index.html
JavaScript
2
star
26

salestrest

Salestrest
Ruby
2
star
27

php-form-to-xml

PHP
1
star
28

kohMonitor-rails

Ruby
1
star
29

SoccerMom

A easy way to automate setting up SSH tunnels, specifically socks tunnels to make working remotely as seamless as possible.
Shell
1
star
30

node-starter

JavaScript
1
star
31

RaygunRuby

Raygun api for ruby on rails
Ruby
1
star
32

mysql-binaries

1
star
33

4sqWidget

Foursquare Desktop Widget
JavaScript
1
star
34

apothecary

An open-source e-commerce solution in elixir.
1
star
35

teenage_mutant_ninja_graphs

Ruby
1
star
36

sms-app-url

Easily send an app url to mobile users via SMS using Twilio.
Ruby
1
star
37

ember-mobile

A Mobile UIKit for EmberJS
JavaScript
1
star
38

mattermark-chrome

A chrome extension that will pull Mattermark information for the company whose site you are on.
JavaScript
1
star
39

girara-osx

A osx compatible build script for girare *require for jumanji"
C
1
star
40

middleman-emberscript

Middleman emberscript support
Ruby
1
star
41

nginx-rtmp-docker

Nginx
1
star
42

try_git

1
star
43

faye-rainbows-rails

Ruby
1
star
44

ember-cli-simple-auth-mattermark

A Ember Simple Auth adapter for the Mattermark api
JavaScript
1
star
45

html5transcoder

Transcode various formats such as apple's caf audio format on the fly with ruby and padrino
Ruby
1
star
46

node-docker-starter

A starter kit for node.js babel and docker, uses pm2 and pre-compiles babeljs on build.
JavaScript
1
star
47

rack_unzip

Ruby
1
star