Coder Social home page Coder Social logo

capistrano-env_config's Introduction

Gem Version

capistrano-env_config

A tool for managing your environment variables across your cluster. The library manipulates the system-wide environment variables by modifying the /etc/environment file.

Usage

  • cap env:list – To list current environment configuration
  • cap env:get[VARIABLE_NAME, VARIABLE_NAME, ...] – To get the value of a list of variables
  • cap env:unset[VARIABLE_NAME, VARIABLE_NAME, ...] – To delete environment variables
  • cap env:set[VARIABLE_NAME=VALUE, VARIABLE_NAME=VALUE, ...] – To set environment variables
  • cap env:sync – To synchronise the environment configuration across servers

If you need to programatically manipulate the environment you can use the Capistrano::EnvConfig::Environment class like so:

require 'capistrano/env_config/environment'

environment = Capistrano::EnvConfig::Environment.new # Reads and loads /etc/environment from all servers
environment.list # Returns a hash of all environment variables
environment.get( 'VARIABLE' ) # Gets a variable by name
environment.set( 'VARIABLE', 'VALUE' ) # Sets a variable
environment.delete( 'VARIABLE' ) # Deletes a variable
environment.sync # Uploads current confifuration to all servers

By default capistrano sets and reads the /etc/environment of all roles. This behaviour can be changed by setting:

set :env_config_roles, [ :web, :app ]

The new and sync methods also accept an optional argument for specifying roles explicitly (overriding the value set in :env_config_roles):

environment.list( :app )
environment.sync( [ :web, :app ] )

Installation

Add the gem to your Gemfile:

group :development do
  gem 'capistrano-env_config'
end

And the following line to your Capfile:

require 'capistrano/env_config'

In your server provisioning script, make sure the deploy user has write access to the /etc/environment file, which is used to store the configured variables.

The simplest way to do that would be to:

chown :deploy /etc/environment
chmod g+w /etc/environment

License

Copyright Itay Grudev (c) 2017.

This gem and all associated documentation is distributed under the terms of the GNU GPL v3 license.

capistrano-env_config's People

Contributors

dependabot[bot] avatar itay-grudev 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.