Ask Your Question

Set global env variable in Apache module

asked 2014-04-13 00:58:03 -0500

I know I can set an environment variable for a specific virtual host via:

 apache::vhost { "":

But how can I set an environment variable for all virtual hosts without repeating myself, i.e., a global environment variable?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-04-14 04:29:13 -0500

vishwanathj gravatar image

Look up which might provide the solution you are looking for. In your case, the resource default according to the above link would look like Apache::Vhost { setenv => ["APPENVIRONMENT DEVELOPMENT"], } Please confirm if this works for you.

edit flag offensive delete link more


This works well and allows me to manage global environment variables in an elegant way. I should note that it doesn't actually set a global environment variable -- the SetEnv ...(more)

Ryan Sechrest gravatar imageRyan Sechrest ( 2014-04-14 09:59:11 -0500 )edit

answered 2014-04-13 11:19:52 -0500

I believe inherits could solve your problem like create a base apache node and inherits for the others

node base-apache {
apache::vhost {"baseapache":
and then use the inherits.
node machinename inherits base-apache {


the code wasn't tested , maybe need some adjust.

edit flag offensive delete link more


Inheritance seems overly complex for this, since I could use a variable for this as well. I was looking for a way to set the environment variable globally (not within ...(more)

Ryan Sechrest gravatar imageRyan Sechrest ( 2014-04-13 13:24:02 -0500 )edit

I can't see a way to do that without using a inherits or hiera.

Renan Vicente gravatar imageRenan Vicente ( 2014-04-13 17:47:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2014-04-13 00:58:03 -0500

Seen: 1,251 times

Last updated: Apr 14 '14