Ask Your Question
2

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 { "domain.com":
   setenv  => ["APP_ENVIRONMENT DEVELOPMENT"],
 }

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
2

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

vishwanathj gravatar image

Look up http://docs.puppetlabs.com/puppet/latest/reference/langdefaults.html 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

Comments

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
1

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":
  setenv => ["APP_ENVIRONMENT DEVELOPMENT"],
}
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

Comments

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

2 followers

Stats

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

Seen: 1,302 times

Last updated: Apr 14 '14