flexible Rails deployment with Ansible
Clone or download
Latest commit d5f5f6e Oct 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
apache cleaned when conditions Oct 8, 2018
database/backup Merge pull request #34 from arBmind/feature/remove-newlines Apr 28, 2016
firewalld minor style adjustments in the database/backup, firewalld and meta role Apr 6, 2016
git/env-credentials fixed script name and typo in configured user Dec 12, 2016
meta minor style adjustments in the database/backup, firewalld and meta role Apr 6, 2016
nginx Reliably enable and start nginx on systemdified Debianoids Oct 2, 2018
postgresql Added python3 compatibility Oct 31, 2017
puma cleaned when conditions Oct 8, 2018
rails fix missing git_user Oct 8, 2018
ruby fixed gem_version comparison Jul 5, 2016
selinux some adjustments and refactorings Apr 16, 2015
ssh_agent added support for ssh_agent forwarding through ssh and sudo Jan 11, 2015
tests switched to ubuntu-upstart for 14.04, improved session init in Ansible Jul 22, 2016
unicorn cleaned when conditions Oct 8, 2018
upstart/userjobs switched to ubuntu-upstart for 14.04, improved session init in Ansible Jul 22, 2016
user/profile Merge pull request #34 from arBmind/feature/remove-newlines Apr 28, 2016
webrick cleaned when conditions Oct 8, 2018
yarn Add Webpack + Yarn usage by simple new flag `rails_webpacker` Nov 23, 2017
.gitignore added a gitignore file and ignore all *.retry files, ported postgresq… Apr 6, 2016
.travis.yml Change docker exec parameters Oct 2, 2018
LICENSE updated license year Jan 31, 2015
README.md Merge branch 'develop' into sidekiq_system Jun 3, 2018

README.md

dresden-weekly.Rails

Ansible Galaxy Build Status

Our think-tank for modules and playbooks that help to deploy Ruby on Rails applications

This repository contains many roles that you can glue together to represent your individual Rails deployment.

Requirements

  • Ubuntu 12.04 (Precise)
  • Ubuntu 14.04 (Trusty)
  • CentOS 7

Content Roles

Provisioning:

  • user/profile store facts to .profile and .bashrc
  • postgresql install a PostgreSQL 9.3 database
  • database/backup Simple rotating SQL dump backups
  • upstart/userjobs enables Upstart userjobs
  • ruby/rvm installs a specific Ruby version with rvm
  • ruby/rbenv installs a specific Ruby version with rbenv
  • ruby/postgresql support for PostgreSQL client gems
  • ruby/imagemagick installs the popular image manipulation tool with support for rmagick binding and some image optimization libraries
  • ruby/sqlite3 support for sqlite3 client gems
  • ruby/mysql support for Mysql client gems
  • rails/create-folders prepares a folder for Rails releases
  • rails/logrotate create logrotate configuration for Rails logs
  • rails/jobs/sidekiq manage/restart sidekiq as a upstart job or Systemd unit
  • rails/jobs/mailroom manage/restart Mailroom as an systemd job (Ubuntu 16+) to listen for incoming emails in time
  • nginx/server install Nginx webserver
  • nginx/passenger install Nginx webserver
  • nginx/puma prepare nginx for Puma appserver
  • nginx/webrick prepare nginx for Webrick apperserver
  • puma/upstart install userjob for Puma
  • webrick/service setup init system to start Webrick
  • apache/server install and configure Apache server
  • apache/passenger install and configure Passenger for apache
  • apache/vhost add an Apache vhost configuration
  • firewalld configure firewalld (for CentOS)
  • selinux currently only enable/disable selinux on CentOS
  • yarn Installs nodejs + yarn (default nodejs-6.x)

Deployment:

  • rails/create-release create a new release from a git repo
  • rails/use-vagrant create the vagrant release from a vagrant share
  • rails/tasks/bundle install all bundles gems
  • rails/jobs/sidekiq/restart see Sidekiq role
  • rails/tasks/migrate-database run Rails database migrations
  • rails/tasks/compile-assets create the precompiled assets
  • rails/publish-assets transfer compiled assets from app- to web-servers
  • rails/update-current change the symlink for the current release
  • rails/tasks/whenever update crontab of app user using whenever Gem
  • rails/cleanup-old-releases only keep N last releases
  • rails/rollback rollback the the previous and delete the current release
  • rails/tasks/rake Run arbitrary Rake task on app

Dependencies

no other roles currently

You may want to use our vagrant-ansible-remote for testing and deploying

Example Playbook

Github based single tier deployment

dresden-weekly/ansible-rails-example@simple

  • Git based deployment
  • single tier
  • PostgreSql database
  • Nginx Webserver
  • Webrick as application server
  • Support for Vagrant based development

dresden-weekly/ansible-rails-example@threetier

  • like simple but for classic 3-tier deployment
    1. database
    2. rails application servers
    3. web-servers

hicknhack-software/ansible-redmine-example

  • stable version based deployment
  • single tier with Git and Subversion hosting
  • MySql database
  • Apache webserver
  • Passenger as application server
  • customized for Redmine

stefanwienert.de/ansible

  • Blog post that explains on how to use this role for deploying a Rails app

Changelog

0.3 (stables) planned

  • (Your pull requests are welcome)

0.2 (more features!) 13.05.2015

  • Features
    • multiple machine deployment (see three tier example)
    • skip deploy if nothing changed (using stable release names)
  • Webserver
    • Apache (see redmine example)
  • Rails Application Server
    • Passenger on Apache
  • Database support
    • MySql (see redmine example)
    • Sqlite3
  • Ruby installation
    • rbenv (contributed by @tnt)
  • Linux distribution
    • CentOS (simple)

0.1 (first release) 09.01.2015

  • Features
    • Windows Vagrant support
    • Simple Remote-Tool to trigger deployments
  • Release Management
    • Git based release management
    • Vagrant shared folder based releases for development
  • Webservers
    • nginx
  • Rails application servers
    • puma
    • webrick
  • Database support
    • PostgreSql
  • Ruby installation
    • RVM
  • Configuration management
    • Deployment User environment variables
  • Linux distributions
    • Ubuntu 12.04
    • Ubuntu 14.04

Roadmap

  • Release Management
    • Download based releases
  • Webserver
    • Passenger Standalone
  • Rails Application Server
    • Passenger on NGINX
    • Thin
    • Unicorn
  • Ruby installation
    • Package based
  • Configuration management
    • Generator for secrets.yml
    • Generator for database.yml
  • Linux distribution
    • Ubuntu 15.04
    • CentOS (remaining parts)

License

The MIT License (MIT)

Copyright (c) 2015 dresden-weekly

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.