Luca Gioppo
2013-Jan-16 11:19 UTC
[Puppet Users] how to add an evironment variable to puppet agent execution?
I''m creating a module for the WSO2 products and the tool needs to find the JAVA_HOME that is not set. Java get installed but than the wso2server complains about the missing JAVA_HOM. Checked java -version in shell and it works, but as expected executing echo $JAVA_HOME returns null. So the problem is setting the JAVA_HOME to the user (in this case root). Tryed to append info to .bash_profile but obviously it has to be reloaded and it seems that even with this exec: exec { "reload_${name}_env" : command => "source ~/.bash_profile", cwd => "/root", provider => ''shell'', require => Exec["add_java_home_${name}"] } the reload is not good for the step where the exec of the wso2 is done, so no way to send the new env var to the final exec. How is possible in a easy and working way to set env vars with puppet in a way that get known to following steps? Thanks Luca -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/mzOMA0X4EnwJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
nicolas vigier
2013-Jan-16 11:24 UTC
Re: [Puppet Users] how to add an evironment variable to puppet agent execution?
On Wed, 16 Jan 2013, Luca Gioppo wrote:> > How is possible in a easy and working way to set env vars with puppet in a > way that get known to following steps?You can set environment variables for an exec using the environment parameter : http://docs.puppetlabs.com/references/latest/type.html#exec -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2013-Jan-16 16:11 UTC
[Puppet Users] Re: how to add an evironment variable to puppet agent execution?
On Wednesday, January 16, 2013 5:19:43 AM UTC-6, Luca Gioppo wrote:> > I''m creating a module for the WSO2 products and the tool needs to find the > JAVA_HOME that is not set. > > Java get installed but than the wso2server complains about the missing > JAVA_HOM. > > Checked java -version in shell and it works, but as expected executing > echo $JAVA_HOME returns null. > > So the problem is setting the JAVA_HOME to the user (in this case root). > > Tryed to append info to .bash_profile but obviously it has to be reloaded > and it seems that even with this exec: > exec { > "reload_${name}_env" : > command => "source ~/.bash_profile", > cwd => "/root", > provider => ''shell'', > require => Exec["add_java_home_${name}"] > } > > the reload is not good for the step where the exec of the wso2 is done, so > no way to send the new env var to the final exec. > >The Puppet agent does not normally run from a login shell, and it anyway takes care to pass a very sparse environment to commands it spawns. Moreover, no spawned command can change its parent''s environment, nor, therefore, the environment of any sibling command. Thus, manipulating the agent''s environment is not the answer; instead you must declare the Exec resource properly. The best solution is probably Nicolas''s (using the ''environment'' property of your Exec resource), but there are other possibilities. For instance, perhaps the Exec''s command could be a wrapper script that sets the needed environment variables. Better, you could use the ''env'' command to launch the real command with specified extra environment settings. There might be other options as well. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/ANIDI1F1c6EJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.