vagrant-hostmanager 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +16 -0
- data/Gemfile +1 -1
- data/README.md +52 -8
- data/lib/vagrant-hostmanager/action/update_all.rb +0 -2
- data/lib/vagrant-hostmanager/config.rb +13 -11
- data/lib/vagrant-hostmanager/hosts_file.rb +9 -3
- data/lib/vagrant-hostmanager/plugin.rb +1 -1
- data/lib/vagrant-hostmanager/version.rb +1 -1
- data/test/Vagrantfile +6 -1
- metadata +9 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c46205a89edc88b63ee7d7c113e567fb40b1dc84
|
4
|
+
data.tar.gz: 44bfdd6743cd8b5a9ff8e59369c358a655d1af0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7563696329fd2701f04f66e4ea9b6c9d5d7b172cf67a95a1bb568050226b4f3e63f8c37e2b43384cf2ffc2a6f49df5ca6ca104485663e8eed41a2d911ba23962
|
7
|
+
data.tar.gz: 41666ea71d5427d9e23347474b75287d712540119501a5dde0b6491f3fe2caab188eeff2e2a45854f8370f2fc5ea273d26a5a42589de56bfb2b18b4bf104b92f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.5.0
|
4
|
+
### Features
|
5
|
+
* hostmanager now runs *before* provisioning takes place, on `up` action [[#73](https://github.com/smdahlen/vagrant-hostmanager/issues/73)]
|
6
|
+
|
7
|
+
### Bug fixes
|
8
|
+
* properly detect hosts file location on Windows guests [[#67](https://github.com/smdahlen/vagrant-hostmanager/pull/67)]
|
9
|
+
* do not add host if IP cannot be determined [[#85](https://github.com/smdahlen/vagrant-hostmanager/pull/85)]
|
10
|
+
* force moving of hosts file on Linux guests [[#93](https://github.com/smdahlen/vagrant-hostmanager/pull/93)]
|
11
|
+
* allow top-level config options (eg. `ip_resolver`) to propagate to machine configs [[#91](https://github.com/smdahlen/vagrant-hostmanager/issues/91)]
|
12
|
+
|
13
|
+
### Miscelaneous
|
14
|
+
* add passwordless sudo instructions to README [[#95](https://github.com/smdahlen/vagrant-hostmanager/pull/95)]
|
15
|
+
|
16
|
+
[Full diff](https://github.com/smdahlen/vagrant-hostmanager/compare/v1.4.0...v1.5.0)
|
17
|
+
|
18
|
+
|
3
19
|
## 1.4.0
|
4
20
|
### Features
|
5
21
|
* supports vagrant 1.5 [[#80](https://github.com/smdahlen/vagrant-hostmanager/issues/80), [#81](https://github.com/smdahlen/vagrant-hostmanager/pull/81)]
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,16 @@ resolution of multi-machine environments deployed with a cloud provider
|
|
6
6
|
where IP addresses are not known in advance.
|
7
7
|
|
8
8
|
*NOTE:* Version 1.1 of the plugin prematurely introduced a feature to hook into
|
9
|
-
commands other than `vagrant up` and `vagrant destroy`. Version 1.1 broke support
|
9
|
+
commands other than `vagrant up` and `vagrant destroy`. Version 1.1 broke support
|
10
|
+
for some providers. Version 1.2 reverts this feature until a suitable implementation
|
11
|
+
supporting all providers is available.
|
12
|
+
|
13
|
+
***Potentially breaking change in v1.5.0:*** the running order on `vagrant up` has changed
|
14
|
+
so that hostmanager runs before provisioning takes place. This ensures all hostnames are
|
15
|
+
available to the guest when it is being provisioned
|
16
|
+
(see [#73](https://github.com/smdahlen/vagrant-hostmanager/issues/73)).
|
17
|
+
Previously, hostmanager would run as the very last action. If you depend on the old behavior,
|
18
|
+
see the [provisioner](#provisioner) section.
|
10
19
|
|
11
20
|
Installation
|
12
21
|
------------
|
@@ -61,15 +70,26 @@ Vagrant.configure("2") do |config|
|
|
61
70
|
end
|
62
71
|
```
|
63
72
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
73
|
+
### Provisioner
|
74
|
+
|
75
|
+
Starting at version 1.5.0, hostmanager runs before any provisioning occurs. If you
|
76
|
+
would like hostmanager to run after or during your provisioning stage,
|
77
|
+
you can use hostmanager as a provisioner. This allows you to use the provisioning
|
78
|
+
order to ensure that hostmanager runs when desired. The provisioner will collect
|
79
|
+
hosts from boxes with the same provider as the running box.
|
68
80
|
|
69
|
-
|
81
|
+
Example:
|
70
82
|
|
71
83
|
```ruby
|
84
|
+
# Disable the default hostmanager behavior
|
85
|
+
config.hostmanager.enabled = false
|
86
|
+
|
87
|
+
# ... possible provisioner config before hostmanager ...
|
88
|
+
|
89
|
+
# hostmanager provisioner
|
72
90
|
config.vm.provision :hostmanager
|
91
|
+
|
92
|
+
# ... possible provisioning config after hostmanager ...
|
73
93
|
```
|
74
94
|
|
75
95
|
Custom IP resolver
|
@@ -92,15 +112,26 @@ config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
|
|
92
112
|
end
|
93
113
|
```
|
94
114
|
|
115
|
+
Passwordless sudo
|
116
|
+
-----------------
|
117
|
+
|
118
|
+
Add the following snippet to the sudoers file (for example, to
|
119
|
+
```/etc/sudoers.d/vagrant_hostmanager```) to make it stop asking
|
120
|
+
password when updating hosts file (replace ```/home/user``` with your
|
121
|
+
actual home directory):
|
122
|
+
|
123
|
+
Cmnd_Alias VAGRANT_HOSTMANAGER_UPDATE = /bin/cp /home/user/.vagrant.d/tmp/hosts.local /etc/hosts
|
124
|
+
%sudo ALL=(root) NOPASSWD: VAGRANT_HOSTMANAGER_UPDATE
|
125
|
+
|
95
126
|
Windows support
|
96
127
|
---------------
|
97
128
|
|
98
|
-
Hostmanager will detect Windows guests and hosts and use the appropriate
|
129
|
+
Hostmanager will detect Windows guests and hosts and use the appropriate
|
99
130
|
path for the ```hosts``` file: ```%WINDIR%\System32\drivers\etc\hosts```
|
100
131
|
|
101
132
|
By default on a Windows host, the ```hosts``` file is not writable without
|
102
133
|
elevated privileges. If hostmanager detects that it cannot overwrite the file,
|
103
|
-
it will attempt to do so with elevated privileges, causing the
|
134
|
+
it will attempt to do so with elevated privileges, causing the
|
104
135
|
[UAC](http://en.wikipedia.org/wiki/User_Account_Control) prompt to appear.
|
105
136
|
|
106
137
|
### UAC limitations
|
@@ -108,6 +139,19 @@ it will attempt to do so with elevated privileges, causing the
|
|
108
139
|
Due to limitations caused by UAC, cancelling out of the UAC prompt will not cause any
|
109
140
|
visible errors, however the ```hosts``` file will not be updated.
|
110
141
|
|
142
|
+
Installing development version
|
143
|
+
------------------------------
|
144
|
+
|
145
|
+
If you want to install the bleeding version of vagrant-hostmanager (*at your own risk*), you can do the following
|
146
|
+
(requires ruby and git):
|
147
|
+
|
148
|
+
```
|
149
|
+
git clone https://github.com/smdahlen/vagrant-hostmanager.git
|
150
|
+
cd vagrant-hostmanager
|
151
|
+
rake gem:build
|
152
|
+
vagrant plugin install pkg/vagrant-hostmanager-*.gem
|
153
|
+
```
|
154
|
+
|
111
155
|
Contribute
|
112
156
|
----------
|
113
157
|
Contributions are welcome.
|
@@ -23,8 +23,6 @@ module VagrantPlugins
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def call(env)
|
26
|
-
# skip if machine is already active on up action
|
27
|
-
return @app.call(env) if @machine.id && env[:machine_action] == :up
|
28
26
|
# skip if machine is not active on destroy action
|
29
27
|
return @app.call(env) if !@machine.id && env[:machine_action] == :destroy
|
30
28
|
|
@@ -13,20 +13,22 @@ module VagrantPlugins
|
|
13
13
|
alias_method :manage_host?, :manage_host
|
14
14
|
|
15
15
|
def initialize
|
16
|
-
@enabled
|
17
|
-
@manage_host
|
18
|
-
@ignore_private_ip
|
19
|
-
@include_offline
|
20
|
-
@aliases
|
21
|
-
@
|
22
|
-
@include_offline = false
|
23
|
-
@ip_resolver = nil
|
16
|
+
@enabled = UNSET_VALUE
|
17
|
+
@manage_host = UNSET_VALUE
|
18
|
+
@ignore_private_ip = UNSET_VALUE
|
19
|
+
@include_offline = UNSET_VALUE
|
20
|
+
@aliases = UNSET_VALUE
|
21
|
+
@ip_resolver = UNSET_VALUE
|
24
22
|
end
|
25
23
|
|
26
24
|
def finalize!
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
25
|
+
@enabled = false if @enabled == UNSET_VALUE
|
26
|
+
@manage_host = false if @manage_host == UNSET_VALUE
|
27
|
+
@ignore_private_ip = false if @ignore_private_ip == UNSET_VALUE
|
28
|
+
@include_offline = false if @include_offline == UNSET_VALUE
|
29
|
+
@aliases = [] if @aliases == UNSET_VALUE
|
30
|
+
@ip_resolver = nil if @ip_resolver == UNSET_VALUE
|
31
|
+
|
30
32
|
@aliases = [ @aliases ].flatten
|
31
33
|
end
|
32
34
|
|
@@ -10,11 +10,15 @@ module VagrantPlugins
|
|
10
10
|
realhostfile = '/etc/inet/hosts'
|
11
11
|
move_cmd = 'mv'
|
12
12
|
elsif (machine.communicate.test("test -d $Env:SystemRoot"))
|
13
|
-
|
13
|
+
windir = ""
|
14
|
+
machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
|
15
|
+
windir << contents.gsub("\r\n", '') if type == :stdout
|
16
|
+
end
|
17
|
+
realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts"
|
14
18
|
move_cmd = 'mv -force'
|
15
19
|
else
|
16
20
|
realhostfile = '/etc/hosts'
|
17
|
-
move_cmd = 'mv'
|
21
|
+
move_cmd = 'mv -f'
|
18
22
|
end
|
19
23
|
# download and modify file with Vagrant-managed entries
|
20
24
|
file = @global_env.tmp_path.join("hosts.#{machine.name}")
|
@@ -80,7 +84,9 @@ module VagrantPlugins
|
|
80
84
|
ip = get_ip_address(machine, resolving_machine)
|
81
85
|
host = machine.config.vm.hostname || machine.name
|
82
86
|
aliases = machine.config.hostmanager.aliases.join(' ').chomp
|
83
|
-
|
87
|
+
if ip != nil
|
88
|
+
"#{ip}\t#{host} #{aliases}\n"
|
89
|
+
end
|
84
90
|
end
|
85
91
|
|
86
92
|
def get_ip_address(machine, resolving_machine)
|
@@ -17,7 +17,7 @@ module VagrantPlugins
|
|
17
17
|
end
|
18
18
|
|
19
19
|
action_hook(:hostmanager, :machine_action_up) do |hook|
|
20
|
-
hook.
|
20
|
+
hook.after(Vagrant::Action::Builtin::Provision, Action.update_all)
|
21
21
|
end
|
22
22
|
|
23
23
|
action_hook(:hostmanager, :machine_action_destroy) do |hook|
|
data/test/Vagrantfile
CHANGED
@@ -33,4 +33,9 @@ Vagrant.configure('2') do |config|
|
|
33
33
|
server.vm.network :private_network, :ip => '10.0.5.4'
|
34
34
|
server.vm.provision :hostmanager
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
config.vm.define :server4 do |server|
|
38
|
+
server.vm.hostname = 'scruffy'
|
39
|
+
server.vm.provision :hostmanager
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hostmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Shawn Dahlen
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,17 +27,15 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: A Vagrant plugin that manages the /etc/hosts file within a multi-machine
|
@@ -76,27 +71,26 @@ files:
|
|
76
71
|
homepage:
|
77
72
|
licenses:
|
78
73
|
- MIT
|
74
|
+
metadata: {}
|
79
75
|
post_install_message:
|
80
76
|
rdoc_options: []
|
81
77
|
require_paths:
|
82
78
|
- lib
|
83
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
80
|
requirements:
|
86
|
-
- -
|
81
|
+
- - '>='
|
87
82
|
- !ruby/object:Gem::Version
|
88
83
|
version: '0'
|
89
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
85
|
requirements:
|
92
|
-
- -
|
86
|
+
- - '>='
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: '0'
|
95
89
|
requirements: []
|
96
90
|
rubyforge_project:
|
97
|
-
rubygems_version:
|
91
|
+
rubygems_version: 2.0.14
|
98
92
|
signing_key:
|
99
|
-
specification_version:
|
93
|
+
specification_version: 4
|
100
94
|
summary: A Vagrant plugin that manages the /etc/hosts file within a multi-machine
|
101
95
|
environment
|
102
96
|
test_files:
|