# Revision history [back]

### Exec and system-wide environment variables (CentOS)

Hi, I am setting up a system-wide environment variable so multiple users can use the setting. The issue is that the command executes properly, but I can't get it to run only once - every time I run the puppet agent on the node the exec executes. How can I get the exec to set the DATA_DIR and only fire if the DATA_DIR changes for some reason?

#Create the system-wide environment variable file mix.sh and populate it with content

  file { '/etc/profile.d/mix.sh':
ensure  =>  present,
content => 'export DATA_DIR=/opt/data/Buildings',
}


Then the exec: I invoke /etc/profile to run in order to pick up /etc/profile.d/mix.sh and the newly created DATA_DIR environment variable within it. That works fine, but the exec fires every time I run the puppet agent as opposed to only running if there is a change to mix.sh I though that adding the subscribe attribute would control how often the exec ran, but that didn't control it's behavior:

exec { 'add-DATA_DIR ':
provider => shell,
command  => '. /etc/profile',  #use dot command to run the /etc/profile file
subscribe  => File['/etc/profile.d/mix.sh'],
}