Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Manage Environment Variables for Continuous Deployment

So, a common practice these days is to put connection strings & passwords as environment variables to avoid their being placed into a file. This is all fine and dandy, but I'm not sure how to make this work when trying to set up a continuous deployment workflow with some configuration management tool such as Salt/Ansible or Chef/Puppet.

Specifically, I have the following questions in environments using the above mentioned configuration management tools:

  1. Where do you store connection strings/passwords/keys separate from codebases?
    • Do you keep those items in a code-repo of some type (git, etc.)?
    • Do you use some structure built-in to your tool?
  2. How do you keep those same items secure?
  3. Do you track changes/back-up these items, and if so, how?
like image 921
eikonomega Avatar asked Jan 09 '14 15:01

eikonomega


People also ask

How do you manage environment variables?

There are multiple solutions: you ask each developer to set the value in their environment before launching the application. you add some logic at the application's initialization to use the API key environment variable value if it exists, otherwise, fall back to the plain configuration file.

Can you change the environment variables of a running process?

In general, you can only influence a process's environment variables at the time the process starts up. If you need to communicate a change to a running process, the environment isn't the right tool.


1 Answers

In Chef you can

  1. store passwords or API tokens in either encrypted data bags or using chef-vault. They are then decrypted while chef does the provisioning (with encrypted data bags using a shared secret, with chef-vault using the existing PKI of Chef client).
  2. set environment variables when calling external software using the environment parameter of e.g. the execute resource.
  3. not sure, what to write here -- I'd say you don't really manage them. This way you set the variables only for the command that needs it, not e.g. for the whole chef run.
like image 182
StephenKing Avatar answered Oct 29 '22 00:10

StephenKing