PassEnv does not find ENV variables

Posted by quodlibetor on Server Fault See other posts from Server Fault or by quodlibetor
Published on 2012-10-22T19:06:56Z Indexed on 2012/10/22 23:04 UTC
Read the original article Hit count: 193

Filed under:
|

I've got this /etc/profile.d/myfile.sh:

export MYVAR=myval

I also have a PassEnv MYVAR line in a <virtualhost> section of an apache conf dir.

That lets me do things like:

$ echo $MYVAR
myval
$ python
>>> import os; os.getenv('MYVAR')
'myval'
$ sudo echo $MYVAR
myval
$ sudo -i
root# echo $MYVAR
myval

But then, despite that being the case I get:

root# /sbin/service httpd restart
/sbin/service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: [Mon Oct 22 14:44:02 2012] [warn] PassEnv variable MYVAR was undefined
                                                           [  OK  ]

And all of my attempts to access MYVAR from within my wsgi scripts just don't work.

Thoughts? Am I doing something obviously wrong?

EDIT for more detail

I've got a swarm of computers/VMs and a swarm of developers working on a swarm of projects. I need a simple central place to keep environment information, the most common is the "environment" (dev/stage/prod). The scheme that we've got (modifying *.wsgi programmatically) is turning out to be more fragile than we'd like.

The main options that I see are:

  • put things in the shell environment
  • put things in other config files

Getting things into the shell environment is the best, because we won't need to write yet more duplicated "what is my environment" code.

© Server Fault or respective owner

Related posts about apache2

Related posts about wsgi