GithubHelp home page GithubHelp logo

ansistrano-rails's Introduction

ansistrano-rails

Setup and deploy Rails to Ubuntu server via Ansistrano

Description

Ansistrano is a Ansible playbooks to perform deploys in a Capistrano like way.

This repo includes everything required to setup and then deploy Rails on Ubuntu server.

Features

List of installed software

  • Nginx
  • Puma
  • Ruby
  • Delayed Job service

Installation

  • Install ansible
brew install ansible
  • Clone this repo
cd <your project>/config/
git clone [email protected]:2rba/ansistrano-rails.git deploy
  • Download ansistrano and rvm roles (By default it will be stored to ~/.ansible)
cd <your project>/config/deploy/
ansible-galaxy install -r galaxy.yml
  • To allow ssh key forwarding (to access private git repo from server) update ~/.ansible.cfg as:
[defaults]
# human-readable stdout/stderr results display
stdout_callback = yaml

[ssh_connection]
ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s

Configure

This repo root folder has 3 playbooks and 1 inventory file (production.yml)

Playbooks:

  • database.yml to install mysql to Ubuntu server
  • site.yml to prepare Rails env at Ubuntu server
  • deploy.yml to deploy Rails to prepared server

Each of these files is intended to run like ansible-playbook -i production.yml deploy.yml

Inventory file production.yml contains environment specific information: hosts, rails_env, etc ... Pay attention to the group names (oldweb, database), these names are referenced from playbooks, if are you going to change them do it in both places.

Update group_vars/all.yml file with project specific variables. Review and update each playbook you are going to use.

Playbooks features

database.yml

This playbook is designed to install mysql server

  • Creates unprivileged user with sudo access
  • Installs mysql server
  • Adds custom config (templates/mysql.custom.j2), feel free to review it before deploy

site.yml

This playbook is designed to prepare Rails env at Ubuntu server

  • Installs Ruby (check and update version in the file site.xml)
  • Installs Nginx, mysql libs
  • Creates unprivileged user with sudo access
  • Creates puma service
  • Creates delayed job service (feel free to remove related lines if you dont need it)
  • Creates logrotate config file

deploy.yml

This playbook is designed to deploy Rails to prepared server. it contains ansistrano config values. It also reference 2 tasks files prepare.yml and restart.yml

  • The prepare.yml perform shell commands to prepare rails env (bundle, assets:precompile, etc). prepare.yml also has task to copy .env file for dotenv gem. Feel free to remove this task (Copy env file) if you dont need it.
  • The restart.yml executes after current symlink changed. It restarts services (Puma, delayed job) and updates whenever cron jobs

Contribution

PRs, Issues are welcome

License

MIT

ansistrano-rails's People

Contributors

2rba avatar

Stargazers

 avatar

Watchers

 avatar

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.