Tim C
2010-Nov-08 22:01 UTC
[Puppet Users] How can I reload environment variable file using puppet?
Hi I''m trying to setting http_proxy environment variable by adding it to the /etc/environment file. I was wondering how I can force puppet to reload this file whenever the file changes. I have tried a few things and none of them have worked, 1.) exec { "source_environment": command => "source /etc/environment", subscribe => File["/etc/environment"], refreshonly => true } 2.) exec { "source /etc/environment": subscribe => File["/etc/environment"], refreshonly => true } 3.) exec { "export http_proxy="http://localhost:3128"": subscribe => File["/etc/environment"], refreshonly => true } Is there a better way to do this? I just need to ensure that the environment var http_proxy is globally set. -- 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.
Richard Crowley
2010-Nov-08 22:11 UTC
Re: [Puppet Users] How can I reload environment variable file using puppet?
> Hi I''m trying to setting http_proxy environment variable by adding it > to the /etc/environment file. > > I was wondering how I can force puppet to reload this file whenever > the file changes. > > I have tried a few things and none of them have worked, > > 1.) > exec { "source_environment": > command => "source /etc/environment", > subscribe => File["/etc/environment"], > refreshonly => true > } > > > 2.) > exec { "source /etc/environment": > subscribe => File["/etc/environment"], > refreshonly => true > } > > 3.) > exec { "export http_proxy="http://localhost:3128"": > subscribe => File["/etc/environment"], > refreshonly => true > } > > > Is there a better way to do this? I just need to ensure that the > environment var http_proxy is globally set.No subshell will be able to modify the parent''s environment, which is what you''re after. Try setting environment variables in the Puppet process''s environment: rcrowley@wd-40:~$ puppet apply test.pp warning: Could not retrieve fact fqdn notice: /Stage[main]//Exec[sh -c ''echo $HOOAH >/tmp/foo'']/returns: executed successfully rcrowley@wd-40:~$ cat /tmp/foo rcrowley@wd-40:~$ HOOAH=hooah puppet apply test.pp warning: Could not retrieve fact fqdn notice: /Stage[main]//Exec[sh -c ''echo $HOOAH >/tmp/foo'']/returns: executed successfully rcrowley@wd-40:~$ cat /tmp/foo hooah rcrowley@wd-40:~$ Setting values in /etc/environment will probably work provided you restart the Puppet process in question after the contents of that file have been set. Hope that helps, Richard -- 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.
Tim C
2010-Nov-08 22:48 UTC
[Puppet Users] Re: How can I reload environment variable file using puppet?
Thanks for you help. Does that mean that there is no way to do it from inside of a puppet module? On Nov 8, 5:11 pm, Richard Crowley <r...@rcrowley.org> wrote:> > Hi I''m trying to setting http_proxy environment variable by adding it > > to the /etc/environment file. > > > I was wondering how I can force puppet to reload this file whenever > > the file changes. > > > I have tried a few things and none of them have worked, > > > 1.) > > exec { "source_environment": > > command => "source /etc/environment", > > subscribe => File["/etc/environment"], > > refreshonly => true > > } > > > 2.) > > exec { "source /etc/environment": > > subscribe => File["/etc/environment"], > > refreshonly => true > > } > > > 3.) > > exec { "export http_proxy="http://localhost:3128"": > > subscribe => File["/etc/environment"], > > refreshonly => true > > } > > > Is there a better way to do this? I just need to ensure that the > > environment var http_proxy is globally set. > > No subshell will be able to modify the parent''s environment, which is > what you''re after. Try setting environment variables in the Puppet > process''s environment: > > rcrowley@wd-40:~$ puppet apply test.pp > warning: Could not retrieve fact fqdn > notice: /Stage[main]//Exec[sh -c ''echo $HOOAH >/tmp/foo'']/returns: > executed successfully > rcrowley@wd-40:~$ cat /tmp/foo > > rcrowley@wd-40:~$ HOOAH=hooah puppet apply test.pp > warning: Could not retrieve fact fqdn > notice: /Stage[main]//Exec[sh -c ''echo $HOOAH >/tmp/foo'']/returns: > executed successfully > rcrowley@wd-40:~$ cat /tmp/foo > hooah > rcrowley@wd-40:~$ > > Setting values in /etc/environment will probably work provided you > restart the Puppet process in question after the contents of that file > have been set. > > Hope that helps, > > Richard-- 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.
James Bailey
2010-Nov-09 07:12 UTC
Re: [Puppet Users] Re: How can I reload environment variable file using puppet?
On 8 November 2010 22:48, Tim C <tcollins1@gmail.com> wrote:> Thanks for you help. > > Does that mean that there is no way to do it from inside of a puppet > module? >Please forgive I am new to Puppet but the question seem to be does Puppet respond to standard process signals so for example if puppet responds in the modern way to a SIGHUP and rereads it config files then a variable if would be changed, if changed. If it does then sending that signal from inside a Puppet module should work. Jim -- 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
2010-Nov-09 14:49 UTC
[Puppet Users] Re: How can I reload environment variable file using puppet?
On Nov 8, 4:48 pm, Tim C <tcolli...@gmail.com> wrote:> Thanks for you help. > > Does that mean that there is no way to do it from inside of a puppet > module?It means that there is no way at all to do it from inside Puppet that will affect the current execution of Puppet itself. Puppet does a lot of calling out to external programs, however, and if you''re trying to make the environment change effective immediately for something that is performed in such a call then you may be able to do it. I''d recommend creating a custom function for that purpose; the key (Ruby) statement would be writing to the Ruby ENV hash: ENV[''http_proxy''] = ''http://localhost:3128''. You can find more information on writing custom functions here: http://docs.puppetlabs.com/guides/custom_functions.html. Having said all that, I''m curious what you''re trying to do that requires the environment variable to apply to anything in the current Puppet run. There might be an alternative that avoids the problem altogether. John -- 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.