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

Disable specific applications #93

Merged
merged 4 commits into from
Nov 30, 2014

Conversation

otahi
Copy link
Collaborator

@otahi otahi commented Nov 23, 2014

The implementation for #85 .
I want to change like this.


Disabling the plugin

The plugin can be totally skipped by setting config.proxy.enabled to false or empty string ("").
This can be useful to for example disable it for some provider.
Specific applications can be skipped by setting config.proxy.enabled to
a hash( like { svn: false }).
This disabling keeps proxy configurations for applications on the guest.
The configurations must be cleared before disabling if needed.

config.proxy.enabled         # => all applications enabled(default)
config.proxy.enabled = true  # => all applications enabled
config.proxy.enabled = { svn: false, docker: false }
                             # => specific applications disabled
config.proxy.enabled = ""    # => all applications disabled
config.proxy.enabled = false # => all applications disabled

Todos:

  • README
  • spec
  • implementation
  • test

@otahi otahi force-pushed the disable_specific_application branch from f46fe6c to b73020f Compare November 29, 2014 23:42
@otahi
Copy link
Collaborator Author

otahi commented Nov 30, 2014

@tmatilai,
I have implemented the function to disable specific applications. If you have any indications or advices, please give me. I just checked this function work on my vagrant with CentOS7 virtualbox instance. I will cover more instances.

@jperville,
I am trying to solve #85. If possible, I want to ask you to check this function on your environment with Installing a pre-release version.


The unit test result for this function is as follows.

[otahi@otahiair vagrant-proxyconf]$ bundle exec rspec spec/unit/vagrant-proxyconf/action/configure_env_proxy_spec.rb

VagrantPlugins::ProxyConf::Action::ConfigureEnvProxy
  #config_name
    should eq "env_proxy"
  #disabled?
    when both config and proxy are enabled
      should eq false
    when config is enabled and config proxy is not enabled
      should eq true
    when config is enabled and config proxy is empty string
      should eq true
    when config is not enabled and proxy is enabled
      should eq true
    when both config and target proxy are enabled
      should eq false
    when config is enabled and target proxy target is not enabled
      should eq true
    when config is enabled and other proxy are not enabled
      should eq false

Finished in 0.0109 seconds (files took 0.4665 seconds to load)
8 examples, 0 failures
Coverage report generated for RSpec to /Users/otahi/git/vagrant-proxyconf/tmp/coverage. 3635 / 7140 LOC (50.91%) covered.
[Coveralls] Outside the Travis environment, not sending data.
[otahi@otahiair vagrant-proxyconf]$

@jperville
Copy link
Contributor

I just tested the branch on my system with good success (at least to disable the docker proxy). I encountered an error with the git proxy (the /usr/bin/git config --system --unset-all http.proxy command exited with status 5) so I disabled the git proxy also.

Relevant output of vagrant plugin list:

vagrant-proxyconf (1.4.1.dev)
  - Version Constraint: 1.4.1.dev

Here is the configuration snippet in my Vagrantfile:

  if Vagrant.has_plugin?('vagrant-proxyconf')
    config.proxy.enabled = { docker: false, git: false }
  end

When booting the VM, the following proxies were configured:

==> default: Configuring proxy for Apt...
==> default: Configuring proxy for Chef provisioners...
==> default: Configuring proxy environment variables...

LGTM, thank you so much for this PR @otahi

@otahi
Copy link
Collaborator Author

otahi commented Nov 30, 2014

@jperville Thank you for your testing. I'm happy to hear that. I will continue to test some kind of VMs.

@tmatilai
Copy link
Owner

Thanks to both of you!

tmatilai added a commit that referenced this pull request Nov 30, 2014
@tmatilai tmatilai merged commit 7282215 into tmatilai:master Nov 30, 2014
@otahi
Copy link
Collaborator Author

otahi commented Nov 30, 2014

@tmatilai ,
Thank you for your merging. But, I am doing test on some VMs.(CentOS 7, CentOS 6.5, Ubuntu 14.04)
Now, I am thinking there some issues.

  1. chef is not affected because chef has separated call method.
  2. git fails on my VMs as @jperville said
==> centos6: Configuring proxy for Git...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/usr/bin/git config --system --unset-all http.proxy

@tmatilai
Copy link
Owner

@otahi OK. One issue is at least that config.enabled? is not called early enough in some cases. That checks the capability, in git's case if the binary is found.

@otahi
Copy link
Collaborator Author

otahi commented Nov 30, 2014

@tmatilai , Thank you for your advice.

On the VM, git can be run but return 5. I am investigating.

[vagrant@vagrant-centos65 ~]$ sudo /usr/bin/git config --system --unset-all http.proxy ; echo $?
5
[vagrant@vagrant-centos65 ~]$

@otahi
Copy link
Collaborator Author

otahi commented Nov 30, 2014

@tmatilai
I understand git case. Git returns 5 if no configuration exists.

[vagrant@vagrant-centos65 ~]$ sudo /usr/bin/git config --system http.proxy test; echo $?
0
[vagrant@vagrant-centos65 ~]$ sudo /usr/bin/git config --system --unset-all http.proxy; echo $?
0
[vagrant@vagrant-centos65 ~]$ sudo /usr/bin/git config --system --unset-all http.proxy; echo $?
5
[vagrant@vagrant-centos65 ~]$

Now, I don't have enough time. I will do research tommorow JST.
Thank you,

@tmatilai
Copy link
Owner

Ouch, that's a nasty catch in the git API... So that's a bug in the configure_git_proxy action. Never came up as no-one probably explicitly sets config.git_proxy.http = "" or so. Guess we could just ignore the errors when removing the configurations? This is anyway a bit out of scope for this PR.

But I still think that there is a bug here too. We shouldn't be unsetting the git proxy without config.git_proxy being touched.

@otahi otahi changed the title [WIP] Disable specific applications Disable specific applications Dec 1, 2014
@otahi
Copy link
Collaborator Author

otahi commented Dec 4, 2014

I have tested on #96. It seems OK.

@otahi otahi deleted the disable_specific_application branch September 29, 2015 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants