I have access to just a module for our team, where as the global manifests are maintained by infrastructure team. The PATH
variable gets set in the global manifests.
I want to append to the PATH
variable, but puppet ignores my exec block.
file { "/etc/profile.d/set_java_home.sh":
ensure => file,
source => "puppet:///modules/teamXXX/set_java_home.sh",
mode => "u=rw,go=r"
}
Exec { path => [ "\${PATH}", "\${JAVA_HOME}/bin" ] }
How can I append to the PATH
variable?
I should have mentioned, I am looking to enhance the PATH
variable for users's shell environment, rather than puppet's execution environment.
Puppet cannot change the environment of the running shell. No subprocess can - the environment is copied to each child process, which then only has access to its individual copy.
To append something to the PATH
of all new login shells, you need to change the profile
configuration file. If you're using a recent version of bash
, there should be a /etc/profile.d
. You can use a resource like this:
file { '/etc/profile.d/append-java-path.sh':
mode => '644',
content => 'PATH=$PATH:/my/java/home/bin',
}