Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for yum proxy configuration #4

Merged
merged 8 commits into from
Oct 29, 2013
Merged

Add support for yum proxy configuration #4

merged 8 commits into from
Oct 29, 2013

Conversation

tmatilai
Copy link
Owner

I'm not much of an EL distro guy, but it seems that for yum the proxy configuration goes to /etc/yum.conf.

The tricky part is that in the same conf there are lots of other settings too. So we need for example some ugly sed magic to inject our settings in.

@patcon
Copy link

patcon commented Jul 2, 2013

@tmatilai
Copy link
Owner Author

tmatilai commented Jul 2, 2013

I might be wrong, but all I read about yum.conf.d was that it should contain repo configurations. If we can add thing to the [main] section from there that would be perfect. I guess we just need to try it out.

@razorsedge
Copy link

I am an EL guy. Adding proxy to YUM is as simple as echo "proxy=http://proxyhost:3128/" >>/etc/yum.conf. Just make sure it is in the [main] section.

@tmatilai
Copy link
Owner Author

Hi Mike,

Thanks for the confirmation. Ensuring the [main] section and idempotence makes the feature a bit trickier than a plain echo, but it is of course totally doable. I just haven't gotten to implement it yet, especially as I was not sure anyone would use it. =)

@imavroukakis
Copy link

Definitely would use it.It's a killer for me right now as I'm behind a corporate proxy.

@tmatilai
Copy link
Owner Author

@imavroukakis Thanks for letting me know. I have a working spike but will need to clean up the code. So it is really coming on some point. =)

Do you have just a yum proxy or a generic http proxy? In the latter case you probably want to configure all the box to use the proxy, i.e. use config.proxy or config.env_proxy settings. Yum should respect the http_proxy environment variables that it puts to place.

@imavroukakis
Copy link

Isn't config.proxy dependant upon vagrant-proxyconf? The issue here is that
vagrant itself doesn't respect system proxy settings, so it's a bit of a
chicken-egg problem (i.e. can't install the vagrant plugin in the first
place). Even when I did (after some considerable hoop jumping) yum seems to
ignore the settings :(

On 23 October 2013 12:56, Teemu Matilainen notifications@github.com wrote:

@imavroukakis https://github.com/imavroukakis Thanks for letting me
know. I have a working spike but will need to clean up the code. So it is
really coming on some point. =)

Do you have just a yum proxy or a generic http proxy? In the latter case
you probably want to configure all the box to use the proxy, i.e. use
config.proxy or config.env_proxy settings. Yum should respect the
http_proxy environment variables that it puts to place.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-26898759
.

@tmatilai
Copy link
Owner Author

@imavroukakis, here is a long reply which doesn't mean that I wouldn't implement this feature. Just trying to help and understand. =)

Isn't config.proxy dependant upon vagrant-proxyconf?

config.proxy.http_proxy etc. set the same value to all other components (e.g. env vars, chef, apt), so that you don't need to duplicate the configurations. See the documentation for more details.

The issue here is that vagrant itself doesn't respect system proxy settings, so it's a bit of a chicken-egg problem (i.e. can't install the vagrant plugin in the first place).

vagrant-proxyconf only ever configures the virtual machines, so it won't help you here even if it installed.

Vagrant plugins are gems. And Vagrant uses its own custom configuration for Rubygems, so you can't use ~/.gemrc. But you can set the http_proxy environment variable in your host machine, for example in posix shells:

http_proxy="http://my.proxy:8080" vagrant plugin install vagrant-proxyconf

Another option is to download the plugin/gem manually from https://rubygems.org/gems/vagrant-proxyconf and install with:

vagrant plugin install path/to/vagrant-proxyconf-0.6.0.gem

Even when I did (after some considerable hoop jumping) yum seems to ignore the settings :(

How is yum invoked? Via a provisioner (chef/puppet/shell?), or after SSH'ing to the box? Is /etc/profile.d/proxy generated correctly? Does echo $http_proxy display the correct value on the box?

@imavroukakis
Copy link

Not at all, thanks for the tip about Rubygems! Unfortunately I am on a very restricted windows environment, would vagrant look for http_proxy as a windows env var?
Yum is invoked via puppet and the proxy variable looks ok, I think this was more of a pebkac rather than a real issue. The problem I think remains with vagrant itself not having deeper proxy integration.

@tmatilai
Copy link
Owner Author

would vagrant look for http_proxy as a windows env var?

Yes it should work just the same. And in the case of plugins it is not Vagrant but Rubygems. You should be able to set the env var with:

set http_proxy=http://my.proxy:8080

I think @tknerr has more experience here if you can't get it to work.

@imavroukakis
Copy link

Thanks Teemu I'll give it a try.

@tknerr
Copy link

tknerr commented Oct 24, 2013

@imavroukakis I have had my fun with proxies as well ;-)

The differentiation between setting the proxy on the host and on the guest is essential, you can find my notes about it here in the README (note: this was without vagrant-proxyconf at that time)

@tmatilai btw there is still value in supporting yum proxy configuration: a colleague recently mentioned that even though yum itself respects the http_proxy env var the fastestmirror plugin does not, so he had to either disable it or set the proxy in /etc/yum.conf afterwards...

@tmatilai
Copy link
Owner Author

@tknerr And another use case is that someone has only a yum cacher proxy (e.g. apt-cacher-ng) that can not be used as a generic http proxy. So definitely I'll hack this up. Just advancing slowly as spare time is limited and I always seem to get stuck with other issues or with IRC. ;)

@tmatilai
Copy link
Owner Author

Finally I have a seemingly working branch. I would really appreciate all testing, reviewing and comments.

For testing you have to install the plugin from source:

git clone https://github.com/tmatilai/vagrant-proxyconf.git
cd vagrant-proxyconf
git checkout yum-proxy
<VAGRANT_DIR>/embedded/bin/rake build # or just `rake build` if you have ruby installed
vagrant plugin install pkg/vagrant-proxyconf-0.6.1.dev.gem

I'll merge and make a pre-release version soonish unless we find bugs.

tmatilai added a commit that referenced this pull request Oct 29, 2013
Add support for yum proxy configuration
@tmatilai tmatilai merged commit 68fb1aa into master Oct 29, 2013
@tmatilai
Copy link
Owner Author

All right, folks! Now you can test the feature easily by installing a pre-release version:

vagrant plugin install --plugin-prerelease --plugin-source https://rubygems.org vagrant-proxyconf

@tmatilai tmatilai deleted the yum-proxy branch October 30, 2013 03:18
@tmatilai
Copy link
Owner Author

@tknerr by the way, the fastestmirror plugin in CentOS 6.4 seemed to use the env vars just fine on my testing. Maybe your colleague is using some older release? Would be great if you could ask him to test the pre-release version and report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants