Passing http_proxy_host option

856 views
Skip to first unread message

drew khoury

unread,
Sep 30, 2012, 8:18:25 PM9/30/12
to puppet...@googlegroups.com
Hi,

I've been trying to pass the http_proxy_host option to puppet but it's not taking.

I have tried the following:
sudo puppet apply --debug --verbose --http_proxy_host http://user:pa...@fqdn.com.au --modulepath '/tmp/vagrant-puppet/modules-0' /tmp/vagrant-puppet/manifests/default.pp
sudo puppet apply --debug --verbose --http_proxy_host=http://user:pa...@fqdn.com.au --modulepath '/tmp/vagrant-puppet/modules-0' /tmp/vagrant-puppet/manifests/default.pp
sudo puppet apply --debug --verbose --http_proxy_host="http://user:pa...@fqdn.com.au" --modulepath '/tmp/vagrant-puppet/modules-0' /tmp/vagrant-puppet/manifests/default.pp

Do I have a problem with my syntax? Can anyone offer me a proper solution for how to successfully pass the http_proxy_host option to puppet?

I've checked and the settings dont look like they've taken:

# DEBUG
# ---------------------------------------------------------------
vagrant@vagrant-debian-squeeze:~$ puppet --configprint all | grep proxy
http_proxy_host = none
http_proxy_port = 3128
# ---------------------------------------------------------------

# INFO
# ---------------------------------------------------------------
vagrant@vagrant-debian-squeeze:/tmp/vagrant-puppet/manifests$ sudo apt-show-versions | grep puppet
puppet/squeeze uptodate 2.6.2-5+squeeze6
puppet-common/squeeze uptodate 2.6.2-5+squeeze6
# ---------------------------------------------------------------


I should say I originally tried to do this with Vagrant (see here for more info https://groups.google.com/forum/?fromgroups=#!topic/vagrant-up/IW97AZbxdVc ) although I eventually realised I couldn't even do this through puppet so I'm keen on trying to solve both issues.

Thanks, Drew.

drew khoury

unread,
Sep 30, 2012, 8:36:48 PM9/30/12
to puppet...@googlegroups.com
Also I tried upgrading puppet and got the same results.

vagrant@vagrant-debian-squeeze:/tmp/vagrant-puppet/manifests$ sudo apt-show-versions | grep puppet
facter/squeeze uptodate 1.6.12-1puppetlabs2
puppet/squeeze uptodate 2.7.19-1puppetlabs2
puppet-common/squeeze uptodate 2.7.19-1puppetlabs2
puppetlabs-release/squeeze uptodate 1.0-5

Clarence Beeks

unread,
Sep 30, 2012, 9:03:12 PM9/30/12
to puppet...@googlegroups.com
On Sun, Sep 30, 2012 at 5:36 PM, drew khoury <drew....@gmail.com> wrote:
Also I tried upgrading puppet and got the same results.

vagrant@vagrant-debian-squeeze:/tmp/vagrant-puppet/manifests$ sudo apt-show-versions | grep puppet
facter/squeeze uptodate 1.6.12-1puppetlabs2
puppet/squeeze uptodate 2.7.19-1puppetlabs2
puppet-common/squeeze uptodate 2.7.19-1puppetlabs2
puppetlabs-release/squeeze uptodate 1.0-5


Try setting it in puppet.conf and with "export http_proxy=...." like in this thread:


drew khoury

unread,
Sep 30, 2012, 10:15:23 PM9/30/12
to puppet...@googlegroups.com
Setting the env variable manually does work, however I'm trying to run puppet via Vagrant, so I wonder where I have to set the http_proxy variable to get it to work when puppet is loaded via Vagrant.

drew khoury

unread,
Sep 30, 2012, 10:30:35 PM9/30/12
to puppet...@googlegroups.com
Looks like I was able to get it to work by executing the export command through a bash script, initiated via puppets exec logic in my puppet manifest. Not the most elegant solution but good enough to get me working.

I had originally tried setting this in ~/.bashrc but with no luck. Now I'm...
- doing a straight export http_proxy=... (in my bash script)
as well as...
- adding to /home/vagrant/.bashrc

This way puppet gets the proxy at runtime & if I log in as vagrant I get proxy too.

Thanks for pointing me in the right direction!

drew khoury

unread,
Oct 1, 2012, 12:40:42 AM10/1/12
to puppet...@googlegroups.com
May have spoken too soon.

If I set the env variable, and I'm manually logged, then I run puppet all is good.

I'm still not clear on how I set the env variable when puppet is invoked from Vagrant (this might end up being a question for Vagrant not puppet?).

Setting the env variable in a bash script invoked via the puppet manifest proved to be useless, as it doesn't have any scope OUTSIDE the bash script.

I've tried a combination of setting the variable in /home/vagrant/.bashrc AND keeping the env via env_keep in sudoers but I'm not sure I'm understanding how Vagrant is invoking Puppet. 

jcbollinger

unread,
Oct 1, 2012, 10:59:56 AM10/1/12
to puppet...@googlegroups.com


On Sunday, September 30, 2012 11:40:42 PM UTC-5, drew khoury wrote:
May have spoken too soon.

If I set the env variable, and I'm manually logged, then I run puppet all is good.

I'm still not clear on how I set the env variable when puppet is invoked from Vagrant (this might end up being a question for Vagrant not puppet?).


Yes, that would be a Vagrant question.  You could, however, have Vagrant invoke a wrapper script that sets the desired variable instead of invoking "puppet apply" directly.  I'm not sure how that differs from what you tried but it should work.  Something like this:

#!/bin/bash
export http_proxy=my.proxy
puppet apply "$@"

 

Setting the env variable in a bash script invoked via the puppet manifest proved to be useless, as it doesn't have any scope OUTSIDE the bash script.


Indeed not.  That's why you need to put the Puppet invocation inside the script.

 

I've tried a combination of setting the variable in /home/vagrant/.bashrc AND keeping the env via env_keep in sudoers but I'm not sure I'm understanding how Vagrant is invoking Puppet. 


Command runners typically are very careful and selective about the environment they provide to commands they run.  Puppet is a good example, and likely Vagrant is, too.  Such programs normally have a way to configure the environment for each command along with the command itself, and they usually provide little or nothing else in those environments.  In particular, they normally do not pass on their own environment to commands.


John

drew khoury

unread,
Oct 3, 2012, 12:11:42 AM10/3/12
to puppet...@googlegroups.com
hmm I get the concept of the wrapper script, though I'm not too sure how/where to implement within Vagrant. I haven't had much luck on the Vagrant forums, so instead I've decided to simply run a Vagrant reload after it fails the first time (that gives puppet the chance to update bashrc with the proxy, subsequent runs work just fine as you'd expect.

I believe puppet not honouring the http_proxy_host option it has is the real issue, though with this workaround in place, I can live with it. 
Reply all
Reply to author
Forward
0 new messages