Set environment variable in Puppet

puppet

I'd like to set an environment variable on my Linux systems managed by Puppet to contain the name of the currently running branch, puppet's $environment. It needs to be a system level variable from anywhere and any user the system – I'm trying to avoid any kind of file system tomfoolery if at all possible.

Basically I'd like to be able to read this variable in other code and include it in the logs it creates.

Ideally I'm looking for a cross platform answer, but CentOS / RedHat specific would be a great start.

Edit:
I'd like to avoid having some random file under /etc/ that I need to read every time I write a line in my log.

I thought about using profile.d shortly after I posted. Problem is a lot of services don't load the profile, and even if I do use a fragment it'd require rereading the profile if I make a change.

Best Answer

The 'standard' way of doing this is to add a file /etc/profile.d/environment.sh

Containing

export VAR1=value1

As you said, some services (cron) don't start login shells, or don't read the environment, they have to be done in a different way.