GithubHelp home page GithubHelp logo

isabella232 / opsworks_custom_env Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pitchtarget/opsworks_custom_env

0.0 0.0 0.0 121 KB

This chef cookbook writes custom app configuration values from the OpsWorks stack's custom JSON to a config/application.yml file for each app. The figaro gem can help load those values directly into the application's ENV.

License: MIT License

Ruby 100.00%

opsworks_custom_env's Introduction

opsworks_custom_env

This cookbook allows Rails apps on Amazon OpsWorks to separate their configuration from their code. In keeping with Heroku's twelve-factor app, the configuration is made available to the app's environment.

To accomplish this, the cookbook maintains a config/application.yml file in each respective app's deploy directory. E.g.:

---
FOO: "http://www.yahoo.com"
BAR: "1001"

Your application can then load its settings directly from this file, or use Figaro to automatically make these settings available in the app's ENV (recommended).

Configuration values are specified in the stack's custom JSON. Example:

{
  "custom_env": {
    "my_app": {
      "FOO": "http://www.yahoo.com",
      "BAR": "1001"
    }
  },
  
  "deploy": {
    "my_app": {
      "deploy_to": "/srv/www/my_app",
      "symlink_before_migrate": {
        "config/application.yml": "config/application.yml"
      }
    }
  }
}

Note that the symlink_before_migrate attribute is necessary so that OpsWorks automatically symlinks the shared file when setting up release directories or deploying a new version. The deploy_to attribute is usually provided by OpsWorks, but re-including it in the custom JSON allows the recipe to be run outside of OpsWorks events.

Caveats

At the moment, only Unicorn/Nginx-style Rails apps are supported.

Opsworks Set-Up

  • Add custom_env, deploy_to, and symlink_before_migrate attributes to the stack's custom JSON as in the example above.
  • Associate the opsworks_custom_env::configure custom recipe with the Deploy event in your rails app's layer.

A deploy isn't necessary if you just want to update the custom configuration. Instead, update the stack's custom JSON, then choose to Run Command > execute recipes and enter opsworks_custom_env::configure into the Recipes to execute field. Executing the recipe will write an updated application.yml file and restart unicorn workers.

Copyright and License

(c) 2013 Joey Aghion, Artsy. See LICENSE for details.

opsworks_custom_env's People

Contributors

joeyaghion avatar breezeight avatar stephenbaldwin 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.