Thank you for an interesting idea , > Hi Adrian, > > I'm not sure but I imagine by just trying to 'source' the profile within the > current puppet runtime the scope will be lost as it would be called within an > exec? > > Obviously if you are not worried about running puppet multiple times you > might be able to source it in your 'prerun_command' script
I didn't manage to convince puppet to source the profile... I've tried to add in [agent] section prerun_command=/root/somecommand but the command was not executed and I didn't see any log about it. I wonder if prerun_command = echo 'source /etc/profile'|/bin/bash is suposed to work, because for the moment it is not. Next, what I did is to send SIGUSR1 to puppet after updating /etc/profile with something like this exec { "refresh_profile" : command => "/usr/bin/killall -SIGUSR1 puppetd", onlyif => "pidof -x puppetd", path => "/bin:/usr/bin", user => "root", refreshonly => true, } > Otherwise I have one possible (albeit slightly hacky) option. Perhaps you can > drop to ruby to ensure you set the variable JAVA_HOME within the puppet > runtime. Let me give you an example I set-up on my machine: > /tmp/var.sh: > #!/bin/bash > echo $JAVA_HOME > /tmp/java_path > test.pp: > $dummy = inline_template("<% ENV['JAVA_HOME'] = '/opt/java_1.6.0_20' %>") > exec {"a": > command => "/tmp/var.sh", > } My problem is that I do not use exec. What I do is something like this : package { "buildr": ensure => installed, provider => "gem", require => Package["sun-java5-jdk"], } When it tries to install the gem it needs the JAVA_HOME. Apparently if Java_HOME was set before running puppetd, then Java_Home is available to installer. I am not sure what I can do next ... > notice(inline_template("<%= ENV['JAVA_HOME'] %>")) > > And to run it: > > $ puppet test.pp > notice: Scope(Class[main]): /opt/java_1.6.0_20 > notice: /Stage[main]//Exec[a]/returns: executed successfully > $ cat /tmp/java_path > /opt/java_1.6.0_20 > $ > > This shows that the environment variable is available at the scope when ruby > does an exec (the exec resource) and when you try to grab the variable inline > later on. Hopefully the gem provider should see this, but you'll have to make > sure the inline_template runs before the gem does its work. Putting it in a > class (like your "java" puppet class or something) and doing a require on the > class may solve this. > > Of course there is probably a nicer less complicated way of doing this :-). This would be helpful - even if I don't totaly understand how it works - only if I can grab Java_Home from /etc/profile and assign it to $dummy = inline_template("<% ENV['JAVA_HOME'] = 'JAVA_HOME_FROM_PROFILE' %>") -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.