vagrant-proxyconf 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -0
- data/README.md +24 -13
- data/lib/vagrant-proxyconf/action/base.rb +18 -5
- data/lib/vagrant-proxyconf/action/configure_chef_proxy.rb +3 -3
- data/lib/vagrant-proxyconf/action/configure_env_proxy.rb +14 -0
- data/lib/vagrant-proxyconf/config/apt_proxy.rb +0 -3
- data/lib/vagrant-proxyconf/config/env_proxy.rb +0 -4
- data/lib/vagrant-proxyconf/config/key_mixin.rb +4 -2
- data/lib/vagrant-proxyconf/config/proxy.rb +2 -6
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/spec/unit/support/shared/apt_proxy_config.rb +1 -1
- data/spec/unit/vagrant-proxyconf/action/configure_chef_proxy_spec.rb +5 -0
- data/spec/unit/vagrant-proxyconf/config/env_proxy_spec.rb +1 -1
- data/spec/unit/vagrant-proxyconf/config/proxy_spec.rb +10 -0
- metadata +4 -4
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.5.1 / 2013-09-17
|
2
|
+
|
3
|
+
- Configure sudo to preserve the `*_proxy` environment variables ([GH-23][], [GH-25][])
|
4
|
+
* Requires that sudo in VM is configured to support "sudoers.d", i.e. _/etc/sudoers_ contains line `#includedir /etc/sudoers.d`
|
5
|
+
- Fix Chef provisioner configuration if a proxy is set to `false` ([GH-24][])
|
6
|
+
- Create the directories for configuration files if they don't exist ([GH-25][])
|
7
|
+
|
1
8
|
# 0.5.0 / 2013-09-11
|
2
9
|
|
3
10
|
- Set default proxy configuration for all Chef provisioners ([GH-19][], [GH-21][])
|
@@ -51,3 +58,6 @@
|
|
51
58
|
[GH-17]: https://github.com/tmatilai/vagrant-proxyconf/issues/17 "Issue 17"
|
52
59
|
[GH-19]: https://github.com/tmatilai/vagrant-proxyconf/issues/19 "Issue 19"
|
53
60
|
[GH-21]: https://github.com/tmatilai/vagrant-proxyconf/issues/21 "Issue 21"
|
61
|
+
[GH-23]: https://github.com/tmatilai/vagrant-proxyconf/issues/23 "Issue 23"
|
62
|
+
[GH-24]: https://github.com/tmatilai/vagrant-proxyconf/issues/24 "Issue 24"
|
63
|
+
[GH-25]: https://github.com/tmatilai/vagrant-proxyconf/issues/25 "Issue 25"
|
data/README.md
CHANGED
@@ -12,15 +12,32 @@
|
|
12
12
|
[gemnasium]: https://gemnasium.com/tmatilai/vagrant-proxyconf
|
13
13
|
[codeclimate]: https://codeclimate.com/github/tmatilai/vagrant-proxyconf
|
14
14
|
|
15
|
-
A [Vagrant](http://www.vagrantup.com/) plugin that configures the virtual machine to use specified proxies. This is useful for example in case you are behind a corporate proxy, or you have a caching proxy.
|
15
|
+
A [Vagrant](http://www.vagrantup.com/) plugin that configures the virtual machine to use specified proxies. This is useful for example in case you are behind a corporate proxy server, or you have a caching proxy.
|
16
16
|
|
17
17
|
At this state we support:
|
18
18
|
|
19
|
-
* Generic
|
19
|
+
* Generic `http_proxy` etc. environment variables that many programs support
|
20
20
|
* APT proxy/cacher
|
21
21
|
* Setting default proxy configuration for all Chef provisioners
|
22
22
|
|
23
|
-
|
23
|
+
## Quick start
|
24
|
+
|
25
|
+
Install the plugin:
|
26
|
+
|
27
|
+
```sh
|
28
|
+
vagrant plugin install vagrant-proxyconf
|
29
|
+
```
|
30
|
+
|
31
|
+
To configure all possible software on all Vagrant VMs, add the following to _$HOME/.vagrant.d/Vagrantfile_ (or to a project specific _Vagrantfile_):
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Vagrant.configure("2") do |config|
|
35
|
+
config.proxy.http = "http://192.168.0.2:3128/"
|
36
|
+
config.proxy.https = "http://192.168.0.2:3128/"
|
37
|
+
config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
|
38
|
+
# ... other stuff
|
39
|
+
end
|
40
|
+
```
|
24
41
|
|
25
42
|
## Compatibility
|
26
43
|
|
@@ -35,18 +52,10 @@ The following providers are confirmed to work:
|
|
35
52
|
|
36
53
|
For the proxy configuration to take effect for [vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus) plugin, version 1.1.1 or newer of it should be used.
|
37
54
|
|
38
|
-
## Installation
|
39
|
-
|
40
|
-
Install using standard Vagrant plugin installation method:
|
41
|
-
|
42
|
-
```sh
|
43
|
-
vagrant plugin install vagrant-proxyconf
|
44
|
-
```
|
45
|
-
|
46
|
-
See the [wiki](https://github.com/tmatilai/vagrant-proxyconf/wiki) for instructions to install a pre-release version.
|
47
|
-
|
48
55
|
## Usage
|
49
56
|
|
57
|
+
Install using standard Vagrant plugin installation method: `vagrant plugin install vagrant-proxyconf`. See the [wiki](https://github.com/tmatilai/vagrant-proxyconf/wiki) for instructions to install a pre-release version.
|
58
|
+
|
50
59
|
The plugin hooks itself to all Vagrant commands triggering provisioning (e.g. `vagrant up`, `vagrant provision`, etc.). The proxy configurations are written just before provisioners are run.
|
51
60
|
|
52
61
|
Proxy settings can be configured in Vagrantfile. In the common case that you want to use the same configuration in all Vagrant machines, you can use _$HOME/.vagrant.d/Vagrantfile_ or environment variables. Platform specific settings are only used on virtual machines that support them (i.e. Apt configuration on Debian based systems), so there is no harm using global configuration.
|
@@ -100,6 +109,8 @@ VAGRANT_HTTP_PROXY="http://proxy.example.com:8080" vagrant up
|
|
100
109
|
|
101
110
|
Many programs (wget, curl, yum, etc.) can be configured to use proxies with `<protocol>_proxy` or `<PROTOCOL>_PROXY` environment variables. This configuration will be written to _/etc/profile.d/proxy.sh_ on the guest.
|
102
111
|
|
112
|
+
Also sudo will be configured to preserve the variables. This requires that sudo in the VM is configured to support "sudoers.d", i.e. _/etc/sudoers_ contains line `#includedir /etc/sudoers.d`.
|
113
|
+
|
103
114
|
#### Example Vagrantfile
|
104
115
|
|
105
116
|
```ruby
|
@@ -26,7 +26,7 @@ module VagrantPlugins
|
|
26
26
|
env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.not_supported")
|
27
27
|
else
|
28
28
|
env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.configuring")
|
29
|
-
|
29
|
+
configure_machine(machine, config)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -39,7 +39,7 @@ module VagrantPlugins
|
|
39
39
|
|
40
40
|
# @return [Vagrant::Plugin::V2::Config] the configuration
|
41
41
|
def config(machine)
|
42
|
-
config = machine.config.
|
42
|
+
config = machine.config.public_send(config_name.to_sym)
|
43
43
|
finalize_config(config)
|
44
44
|
config.merge_defaults(default_config(machine))
|
45
45
|
end
|
@@ -58,8 +58,19 @@ module VagrantPlugins
|
|
58
58
|
config
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
# Configures the VM based on the config
|
62
|
+
def configure_machine(machine, config)
|
63
|
+
write_config(machine, config)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Writes the config to the VM
|
67
|
+
#
|
68
|
+
# @param opts [Hash] optional file options
|
69
|
+
# @option opts [String] :path (#config_path) the path of the configuration file
|
70
|
+
# @option opts [String] :mode the mode of the file
|
71
|
+
def write_config(machine, config, opts = {})
|
72
|
+
path = opts[:path] || config_path(machine)
|
73
|
+
logger.debug "Configuration (#{path}):\n#{config}"
|
63
74
|
|
64
75
|
temp = Tempfile.new("vagrant")
|
65
76
|
temp.binmode
|
@@ -68,7 +79,9 @@ module VagrantPlugins
|
|
68
79
|
|
69
80
|
machine.communicate.tap do |comm|
|
70
81
|
comm.upload(temp.path, "/tmp/vagrant-proxyconf")
|
71
|
-
comm.sudo("
|
82
|
+
comm.sudo("mkdir -p #{File.dirname(path)}")
|
83
|
+
comm.sudo("cat /tmp/vagrant-proxyconf > #{path}")
|
84
|
+
comm.sudo("chmod #{opts[:mode]} #{path}") if opts[:mode]
|
72
85
|
comm.sudo("rm /tmp/vagrant-proxyconf")
|
73
86
|
end
|
74
87
|
end
|
@@ -52,17 +52,17 @@ module VagrantPlugins
|
|
52
52
|
# @param chef [VagrantPlugins::Chef::Config::Base] the Chef provisioner configuration
|
53
53
|
# @param config [Config::Proxy] the default configuration
|
54
54
|
def configure_chef(chef, config)
|
55
|
-
if chef.http_proxy.
|
55
|
+
if !chef.http_proxy && config.http
|
56
56
|
chef.http_proxy = config.http
|
57
57
|
chef.http_proxy_user = config.http_user
|
58
58
|
chef.http_proxy_pass = config.http_pass
|
59
59
|
end
|
60
|
-
if chef.https_proxy.
|
60
|
+
if !chef.https_proxy && config.https
|
61
61
|
chef.https_proxy = config.https
|
62
62
|
chef.https_proxy_user = config.https_user
|
63
63
|
chef.https_proxy_pass = config.https_pass
|
64
64
|
end
|
65
|
-
if chef.no_proxy.
|
65
|
+
if !chef.no_proxy && config.no_proxy
|
66
66
|
chef.no_proxy = config.no_proxy
|
67
67
|
end
|
68
68
|
end
|
@@ -8,6 +8,20 @@ module VagrantPlugins
|
|
8
8
|
def config_name
|
9
9
|
'env_proxy'
|
10
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def configure_machine(machine, config)
|
15
|
+
super
|
16
|
+
write_config(machine, sudo_config, path: '/etc/sudoers.d/proxy', mode: '0440')
|
17
|
+
end
|
18
|
+
|
19
|
+
def sudo_config
|
20
|
+
<<-CONFIG.gsub(/^\s+/, '')
|
21
|
+
Defaults env_keep += "HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY"
|
22
|
+
Defaults env_keep += "http_proxy https_proxy ftp_proxy no_proxy"
|
23
|
+
CONFIG
|
24
|
+
end
|
11
25
|
end
|
12
26
|
end
|
13
27
|
end
|
@@ -11,15 +11,12 @@ module VagrantPlugins
|
|
11
11
|
include KeyMixin
|
12
12
|
# @!parse extend KeyMixin::ClassMethods
|
13
13
|
|
14
|
-
# @!attribute
|
15
14
|
# @return [String] the HTTP proxy
|
16
15
|
key :http, env_var: 'VAGRANT_APT_HTTP_PROXY'
|
17
16
|
|
18
|
-
# @!attribute
|
19
17
|
# @return [String] the HTTPS proxy
|
20
18
|
key :https, env_var: 'VAGRANT_APT_HTTPS_PROXY'
|
21
19
|
|
22
|
-
# @!attribute
|
23
20
|
# @return [String] the FTP proxy
|
24
21
|
key :ftp, env_var: 'VAGRANT_APT_FTP_PROXY'
|
25
22
|
|
@@ -11,19 +11,15 @@ module VagrantPlugins
|
|
11
11
|
include KeyMixin
|
12
12
|
# @!parse extend KeyMixin::ClassMethods
|
13
13
|
|
14
|
-
# @!attribute
|
15
14
|
# @return [String] the HTTP proxy
|
16
15
|
key :http, env_var: 'VAGRANT_ENV_HTTP_PROXY'
|
17
16
|
|
18
|
-
# @!attribute
|
19
17
|
# @return [String] the HTTPS proxy
|
20
18
|
key :https, env_var: 'VAGRANT_ENV_HTTPS_PROXY'
|
21
19
|
|
22
|
-
# @!attribute
|
23
20
|
# @return [String] the FTP proxy
|
24
21
|
key :ftp, env_var: 'VAGRANT_ENV_FTP_PROXY'
|
25
22
|
|
26
|
-
# @!attribute
|
27
23
|
# @return [String] a comma separated list of hosts or domains which do not use proxies
|
28
24
|
key :no_proxy, env_var: 'VAGRANT_ENV_NO_PROXY'
|
29
25
|
|
@@ -21,6 +21,8 @@ module VagrantPlugins
|
|
21
21
|
# Creates `attr_accessor` for the key name and adds a {Key} to {#keys}.
|
22
22
|
# @param (see Key#initialize)
|
23
23
|
# @option (see Key#initialize)
|
24
|
+
# @!macro [attach] key
|
25
|
+
# @!attribute
|
24
26
|
def key(name, opts = {})
|
25
27
|
self.class_eval { attr_accessor name }
|
26
28
|
keys << Key.new(name, opts)
|
@@ -97,7 +99,7 @@ module VagrantPlugins
|
|
97
99
|
end
|
98
100
|
|
99
101
|
def get(key)
|
100
|
-
|
102
|
+
public_send(key.name)
|
101
103
|
end
|
102
104
|
|
103
105
|
def set?(key)
|
@@ -105,7 +107,7 @@ module VagrantPlugins
|
|
105
107
|
end
|
106
108
|
|
107
109
|
def set(key, value)
|
108
|
-
|
110
|
+
public_send(:"#{key.name}=", value)
|
109
111
|
end
|
110
112
|
|
111
113
|
private
|
@@ -12,19 +12,15 @@ module VagrantPlugins
|
|
12
12
|
include KeyMixin
|
13
13
|
# @!parse extend KeyMixin::ClassMethods
|
14
14
|
|
15
|
-
# @!attribute
|
16
15
|
# @return [String] the HTTP proxy
|
17
16
|
key :http, env_var: 'VAGRANT_HTTP_PROXY'
|
18
17
|
|
19
|
-
# @!attribute
|
20
18
|
# @return [String] the HTTPS proxy
|
21
19
|
key :https, env_var: 'VAGRANT_HTTPS_PROXY'
|
22
20
|
|
23
|
-
# @!attribute
|
24
21
|
# @return [String] the FTP proxy
|
25
22
|
key :ftp, env_var: 'VAGRANT_FTP_PROXY'
|
26
23
|
|
27
|
-
# @!attribute
|
28
24
|
# @return [String] a comma separated list of hosts or domains which do not use proxies
|
29
25
|
key :no_proxy, env_var: 'VAGRANT_NO_PROXY'
|
30
26
|
|
@@ -51,11 +47,11 @@ module VagrantPlugins
|
|
51
47
|
private
|
52
48
|
|
53
49
|
def user(uri)
|
54
|
-
URI.parse(uri).user if
|
50
|
+
URI.parse(uri).user if uri
|
55
51
|
end
|
56
52
|
|
57
53
|
def pass(uri)
|
58
|
-
URI.parse(uri).password if
|
54
|
+
URI.parse(uri).password if uri
|
59
55
|
end
|
60
56
|
end
|
61
57
|
end
|
@@ -29,6 +29,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
|
|
29
29
|
before :each do
|
30
30
|
config.http = 'http://foo:1234'
|
31
31
|
config.http_user = 'bar'
|
32
|
+
config.https = false
|
32
33
|
|
33
34
|
configure_chef
|
34
35
|
end
|
@@ -37,6 +38,9 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
|
|
37
38
|
expect(chef.http_proxy).to eq 'http://foo:1234'
|
38
39
|
expect(chef.http_proxy_user).to eq 'bar'
|
39
40
|
expect(chef.http_proxy_pass).to be_nil
|
41
|
+
expect(chef.https_proxy).to be_nil
|
42
|
+
expect(chef.https_proxy_user).to be_nil
|
43
|
+
expect(chef.https_proxy_pass).to be_nil
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
@@ -47,6 +51,7 @@ describe VagrantPlugins::ProxyConf::Action::ConfigureChefProxy do
|
|
47
51
|
|
48
52
|
config.http = 'http://default:7070/'
|
49
53
|
config.http_user = 'foo'
|
54
|
+
config.http_pass = false
|
50
55
|
config.https = 'http://sslproxy:3128/'
|
51
56
|
|
52
57
|
configure_chef
|
@@ -54,4 +54,14 @@ describe VagrantPlugins::ProxyConf::Config::Proxy do
|
|
54
54
|
its(:https_user) { should eq '' }
|
55
55
|
its(:https_pass) { should eq 'baz' }
|
56
56
|
end
|
57
|
+
|
58
|
+
context "with false" do
|
59
|
+
let(:http_proxy) { false }
|
60
|
+
let(:https_proxy) { false }
|
61
|
+
|
62
|
+
its(:http_user) { should be_nil }
|
63
|
+
its(:http_pass) { should be_nil }
|
64
|
+
its(:https_user) { should be_nil }
|
65
|
+
its(:https_pass) { should be_nil }
|
66
|
+
end
|
57
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-proxyconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Vagrant plugin that configures the virtual machine to use proxies
|
15
15
|
email:
|
@@ -74,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
segments:
|
76
76
|
- 0
|
77
|
-
hash: -
|
77
|
+
hash: -968959479372815338
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
none: false
|
80
80
|
requirements:
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
segments:
|
85
85
|
- 0
|
86
|
-
hash: -
|
86
|
+
hash: -968959479372815338
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
89
|
rubygems_version: 1.8.23
|