Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting environment variables in engineyard

I know from heroku that it’s possible to add environment variables by running heroku config:add MY_ENV_VAR=123 locally. How can I achieve the same thing with engineyard?

like image 445
Clemens Helm Avatar asked Sep 09 '12 20:09

Clemens Helm


People also ask

How do you set environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

Can I use variables in .env file?

The . env file contains the individual user environment variables that override the variables set in the /etc/environment file. You can customize your environment variables as desired by modifying your . env file.

How to set environment variables using the Windows GUI?

Follow the steps to set environment variables using the Windows GUI: 1. Press Windows + R to open the Windows Run prompt. 2. Type in sysdm.cpl and click OK. 3. Open the Advanced tab and click on the Environment Variables button in the System Properties window. 4. The Environment Variables window is divided into two sections.

How to set environment variables in AutoCAD?

Open the Advanced tab and click on the Environment Variables button in the System Properties window. 4. The Environment Variables window is divided into two sections. The sections display user-specific and system-wide environment variables. To add a variable, click the New… button under the appropriate section. 5.

How do I list specific environment variables in the command prompt?

Both the Command Prompt and PowerShell use the echo command to list specific environment variables. The Command prompt uses the following syntax: In Windows PowerShell, use:

What are environment variables in Java?

Environment variables are key-value pairs a system uses to set up a software environment. The environment variables also play a crucial role in certain installations, such as installing Java on your PC or Raspberry Pi.


4 Answers

We ran into the same issue and asked EngineYard for some assistance. Jim Neath from EY came back with the following response:

Unfortunately, passenger does not get passed environment variables from the system. What you need to do is create a ruby wrapper that defines your environment variables and launch passenger using this, as described here:

http://blog.phusion.nl/2008/12/16/passing-environment-variables-to-ruby-from-phusion-passenger/

I have created you a basic custom chef recipe that will do just this:

https://github.com/jimneath/ey-cloud-recipes/tree/master/cookbooks/passenger_env_vars

You will need to update the following file with your environment variables:

/ey-cloud-recipes/blob/master/cookbooks/passenger_env_vars/templates/default/env.custom.erb

like image 98
John Avatar answered Oct 23 '22 21:10

John


I don't think you can =/.

One work-around that we use with our Rails applications is to ssh (ey ssh) to EngineYard and create a file in vim /data/your_app_name/shared/config/exports.rb. This file can look something like this:

ENV["AWS_ACCESS_KEY_ID"] = "your key"
ENV["AWS_SECRET_ACCESS_KEY"] = "your secret"
ENV["AWS_BUCKET"] = "your bucket"

Then in config/boot.rb you require the file:

require File.expand_path('./exports', File.dirname(__FILE__))

This is neither pretty, nor effortless. It however let you use secrets in your app that you should not check into source control!

like image 30
Nicklas Ramhöj Avatar answered Oct 23 '22 20:10

Nicklas Ramhöj


This is pretty simple for Unicorn using env.custom. Take a look at my answer here https://stackoverflow.com/a/13741463/1520775

like image 20
Vlado Cingel Avatar answered Oct 23 '22 20:10

Vlado Cingel


If you want to run a rake task (i.e. cron job) that needs these environmental variables, store the variables in /data/my_app/shared/config/env.custom

source /data/my_app/shared/config/env.custom && cd /data/my_app/current/ && bundle exec rake my_rake_task
like image 31
idrinkpabst Avatar answered Oct 23 '22 21:10

idrinkpabst