32 votes

Using environment variables in Kubernetes deployment spec

A much easier/cleaner solution: envsubst In deploy.yml: LoadbalancerIP: $LBIP Then just create your env var and run kubectl like this: export LBIP="1.2.3.4" envsubst < deploy.yml | kubectl ...
user avatar
  • 457
22 votes

What are the advantages of putting secret values of a website as environment variables?

The author lists their reasoning, although it's a bit disjoint. Their primary argument is that it's easy to accidentally check in a config file, and that config files have varying formats and may be ...
user avatar
17 votes

Setting a variable for a given SSH host

You can give a specific value by using SetEnv in your ~/.ssh/config, e.g. Host * SetEnv FOO=bar As per man ssh_config: Directly specify one or more environment variables and their contents to ...
user avatar
  • 5,797
13 votes

What are the advantages of putting secret values of a website as environment variables?

Environment variables will be inherited by every child process of the web server. That's every session that connects to the server, and every program spawned by them. The secrets will be automatically ...
user avatar
11 votes

Environment variables of a running process on Unix?

While rather sparsely documented, the contents of /proc/<pid>/environ will only contain the environment that was used to start the process. If you need to inspect the current state of a process'...
user avatar
11 votes

What is the best place to setup system wide environment variables on Linux?

A few have answered saying that /etc/environment is depricated and/or not used in Debian anymore, and this is (as at version 7) false. The file is actually read by PAM -- specifically, pam_env(8), ...
user avatar
  • 211
11 votes
Accepted

SSH: Behavior of SetEnv for TERM variable

Update 2021-06-04: "allow ssh_config SetEnv to override $TERM" was just committed to openssh-portable. I assume it's not in a release yet, but I believe this means that, someday soon-ish, ...
user avatar
  • 306
10 votes
Accepted

Tomcat service does not see $JAVA_HOME

This is the expected behavior with systemd. To understand what the environment that systemd services run in, you can refer to man systemd.exec, specifically the section ENVIRONMENT VARIABLES IN ...
user avatar
  • 7,544
10 votes

Why does 'ansible -a "env"' return a different environment PATH than my user?

ansible -a is using the command module and this doesn't use a shell to execute the command. http://docs.ansible.com/ansible/intro_adhoc.html Normally commands also take a -m for module name, but ...
user avatar
  • 10.8k
9 votes

Can the environment variables tool in windows be launched directly?

I recommend this: Open "Run" prompt -> type "SystemPropertiesAdvanced". You will be on the Advanced tab of the System Properties window. From here it's easy. I feel this is an easier command to ...
user avatar
  • 203
9 votes

Security implications of using relative paths in the PATH enivronmental variable?

There are two problems with the path you are using. The path is relative. The relative path comes before the main paths. Lets presume you have the following shell script you use as root to update ...
user avatar
  • 22.6k
8 votes

Is it possible to change value of $TERM when calling ssh?

On 2021-06-04, "allow ssh_config SetEnv to override $TERM" was committed to openssh-portable, which sounds like it will let you set SetEnv TERM in ~/.ssh/config, such as in a Host directive. ...
user avatar
  • 306
8 votes

Apache 2: SetEnvIf "IP Range"

be aware that variables set through SetEnv are not visible on some operations (see matrix): http://www.onlinesmartketer.com/2010/05/27/apache-environment-variables-visibility-with-setenv-setenvif-and-...
user avatar
8 votes
Accepted

How can I use environment variables in haproxy.conf

You are, most likely, using version 1.4 or older. The possibility to use environment variables has been introduced in haproxy 1.5.
user avatar
8 votes
Accepted

Will a Local System service notice changes to environment variables in Windows 2008 R2 without a reboot?

Restarting a service will pickup changes to system environment variables. To check: Use SysInternals Process Explorer to inspect the environment of a service process before and after changing/adding ...
user avatar
  • 3,366
8 votes

Environment variables using AWS CodeDeploy

Amazon has quite an neat feature for this: Parameter Store. You can add key/value pairs there, securely encrypted, and then retrieve them in your CodeDeploy scripts, eg: password=$(aws ssm get-...
user avatar
8 votes

Configure php-fpm to access environment variables in docker

This is a PHP-FPM prank. Setup the clear_env = no on /etc/php/7.2/fpm/pool.d/www.conf, so; On Dockerfile start de php-fpm with init.d, not use service. Ex: CMD /etc/init.d/php7.2-fpm start &&...
user avatar
8 votes
Accepted

Cron job running a Django Python command through a virtual environment not working

There are a couple of ways to solve this: First, it doesn't work because /bin/sh is the shell cron uses to run commands, but /bin/sh doesn't support source. So the quick fix is to set SHELL=/bin/bash ...
user avatar
7 votes

Environment variables of a running process on Unix?

Taken from the Archlinux wiki: You can create a temporary function to parse the values in /proc/<pid>/environ. At the terminal prompt: envof() { sed 's/\x0/\n/g' /proc/${1}/environ; } Then ...
user avatar
  • 171
7 votes

Can I use nginx environment variables within static files that nginx serves?

I've been looking into resolving the same issue as the OP and this post came up in Google search, so thought I'd add a potential solution. This post outlines how you can expose an environment ...
user avatar
  • 171
7 votes
Accepted

How do I view the RDS_ prefixed environment variables in AWS ElasticBeanstalk?

Here's how to do it. First ssh into the eb instance. eb ssh Then un the following command sudo /opt/elasticbeanstalk/bin/get-config environment --output YAML Alternatively --output YAML can be --...
user avatar
7 votes
Accepted

How do you use a variable in a Puppet Manifest?

Have you tried it this way? class excellent { $cool = 'Saturday' class { 'wsus_client': server_url => 'http://acme.com', auto_update_option => 'Scheduled' ...
user avatar
  • 12.3k
7 votes
Accepted

Passing multiple environment variables a process managed by a supervisor

According to http://supervisord.org/configuration.html?highlight=environment, have you tried putting them all on one line? environment=A="1",B="2" (that is, = is used for both environment itself ...
user avatar
  • 4,845
7 votes
Accepted

How to use variables in a systemd service file?

The directive is Environment, not EnvironmentVariable. Environment= Sets environment variables for executed processes. Takes a space-separated list of variable assignments. This option may be ...
user avatar
  • 41.9k
7 votes

Getting environment variables in PHP-FPM with Nginx

You can set the environment variable in /etc/php/php-fpm.d/www.conf like this: env[APP_ENV] = development Then you'll be able to get it with getenv('APP_ENV') like you expected.
user avatar
6 votes
Accepted

Environment variable in /etc/environment with pound (hash) sign in the value

This is read by the pam_env module. Given that the pam_env module expects them to be "simple" KEY=VALUE pairs (doesn't need quotes) and also supports comments identified by #, it assumes that a # and ...
user avatar
6 votes
Accepted

Using HaProxy environmental variables in haproxy.cfg not working

Since you're stopping/starting with the service command, you need to specify the environment variables in your init script (e.g. /etc/init.d/haproxy on ubuntu) not in your interactive terminal session ...
user avatar
  • 3,485
6 votes
Accepted

How configure environment variable with AcceptEnv

You can specify multiple environment variables on one line with AcceptEnv, and you can even give the option multiple times if you want. For example: AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME ...
user avatar
6 votes
Accepted

How to find out the correct path for ANT_HOME in Linux?

On CentOS/Ubuntu ANT_HOME should be /usr/share/ant/. You can check /usr/share/ant/bin/ant, it's just a bash script # load system-wide ant configuration (ONLY if ANT_HOME has NOT been set) if [ -z "$...
user avatar
  • 6,935
6 votes

How to configure environment variables in an IIS 7 application?

Windows 7 SP1 introduced a new default setting for IIS that prevents the loading of profile specific environment variables for IIS application pools. So, for Windows 7 SP1 you additionally need to ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible