I've been struggling with this for a while as well. 

My problem is that I want a specific environment variable set for resources 
not managed through Exec. Specifically I need an installation path for a 
custom type/provider 

I've tried setting variables in /etc/environment but as John points out 
they will not be available in the same puppet run. 
Another option would be to write the path in a temp file and read it out 
later on, but I see this as a hack, not a clean solution.

So do we need an environment attribute for all resources? Any other ideas?

thanks in advance!

Op woensdag 16 januari 2013 17:11:52 UTC+1 schreef jcbollinger:
>
>
>
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/36038b32-6409-4198-9ec6-bcddf6f3deff%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to