Giter Site home page Giter Site logo

ansible-rails-deployment's Introduction

rails-deployment

A role that executes common tasks when deploying ruby on rails applications.

Depends on prepare-release and finalize-release roles to checkout a new version from your git versioned application.

example usage:

---
- hosts: server
  user: app
  gather_facts: False
  vars:
    user: app
    home_directory: "/home/{{ user }}"
    rails_env: "staging"
    deploy_to: "{{ home_directory }}"

  roles:
    -
      role: nicolai86.prepare-release

      repo: [email protected]:app
      branch: develop

      symlinks:
        - { src: "{{ shared_path }}/vendor/bundle", dest: "{{ build_path }}/vendor/bundle" }
        - { src: "{{ shared_path }}/public/assets", dest: "{{ build_path }}/public/assets" }
        - { src: "{{ shared_path }}/log", dest: "{{ build_path }}/log" }
        - { src: "{{ shared_path }}/.env", dest: "{{ build_path }}/.env" }
        - { src: "{{ shared_path }}/config/database.yml", dest: "{{ build_path }}/config/database.yml" }

      directories:
        - "{{ shared_path }}/config"

      templates:
        - { src: "templates/env.js", dest: "{{ shared_path }}/.env" }

      tags: deploy

    -
      role: nicolai86.rails-deployment

      migrate: yes
      compile_assets: yes
      force_migrate: no
      force_asset_compilation: no

      tags: deploy

    -
      role: nicolai86.finalize-release

      tags: deploy

    -
      role: restart

      service: application:*

      tags:
        - deploy
        - rollback

configuration

Most parts of the role can be configured using variables. For example, if you are using rails but using SQL for schema management, you can easily configure rails-deployment to compare the structure.sql files instead of schema.rb like this:

-
  role: nicolai86.rails-deployment

  migrate: yes

  migrate_diff_paths:
    - { current: "{{ current_path }}/db/structure.sql", next: "{{ build_path }}/db/structure.sql" }

See defaults/main.yml for details about available variables.

requirements

  • all gem binaries (e.g. bundle, rake, rails) need to be locateable using the $PATH. Make sure to setup properly

If you are using rbenv to manage your ruby version make sure to properly set the environment using something like this:

environment:
  PATH: '~/.rbenv/shims:~/.rbenv/bin:"$PATH"'

important features:

  • it can be reused multiple times inside a single playbook for separate deployments.
  • works with rvm, rbenv or system ruby installations.
  • it's using a bare copy of the repository to deploy.
  • migration and asset compilation can be de-activated as needed.
  • only keeps 5 most recent deployments per default

limitations

  • you need to write your own restart handling

ansible-rails-deployment's People

Contributors

nicolai86 avatar mortik avatar onemanstartup avatar

Watchers

James Cloos avatar  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.