vagrant-hostmanager 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -18,8 +18,9 @@ command:
|
|
18
18
|
|
19
19
|
$ vagrant hostmanager
|
20
20
|
|
21
|
-
The plugin
|
22
|
-
|
21
|
+
The plugin hooks into the `vagrant up`, `vagrant destroy`, `vagrant halt`,
|
22
|
+
`vagrant resume` and `vagrant suspend` commands automatically.
|
23
|
+
When a machine enters or exits the running state , all active
|
23
24
|
machines with the same provider will have their `/etc/hosts` file updated
|
24
25
|
accordingly. Set the `hostmanager.enabled` attribute to `true` in the
|
25
26
|
Vagrantfile to activate this behavior.
|
@@ -15,10 +15,14 @@ module VagrantPlugins
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
|
-
# skip if machine is
|
19
|
-
return @app.call(env) if @machine.id && env[:machine_action]
|
20
|
-
# skip if machine is not
|
21
|
-
return @app.call(env) if
|
18
|
+
# skip if machine is running and the action is resume or up
|
19
|
+
return @app.call(env) if @machine.state.id == :running && [:resume, :up].include?(env[:machine_action])
|
20
|
+
# skip if machine is not running and the action is destroy, halt or suspend
|
21
|
+
return @app.call(env) if @machine.state.id != :running && [:destroy, :halt, :suspend].include?(env[:machine_action])
|
22
|
+
# skip if machine is not saved and the action is resume
|
23
|
+
return @app.call(env) if @machine.state.id != :saved && env[:machine_action] == :resume
|
24
|
+
# skip if machine is not running and the action is suspend
|
25
|
+
return @app.call(env) if @machine.state.id != :running && env[:machine_action] == :suspend
|
22
26
|
|
23
27
|
# check config to see if the hosts file should be update automatically
|
24
28
|
return @app.call(env) unless @machine.config.hostmanager.enabled?
|
@@ -72,20 +72,19 @@ module VagrantPlugins
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def get_machines
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
machines = []
|
76
|
+
@global_env.machine_names.each do |name|
|
77
|
+
begin
|
78
|
+
machine = @global_env.machine(name, @provider)
|
79
|
+
|
80
|
+
# check if offline machines should be included in host entries
|
81
|
+
if @global_env.config_global.hostmanager.include_offline? || machine.state.id == :running
|
81
82
|
machines << [name, @provider]
|
82
|
-
rescue Vagrant::Errors::MachineNotFound
|
83
83
|
end
|
84
|
+
rescue Vagrant::Errors::MachineNotFound
|
84
85
|
end
|
85
|
-
machines
|
86
|
-
else
|
87
|
-
@global_env.active_machines
|
88
86
|
end
|
87
|
+
machines
|
89
88
|
end
|
90
89
|
|
91
90
|
end
|
@@ -6,7 +6,7 @@ module VagrantPlugins
|
|
6
6
|
name 'HostManager'
|
7
7
|
description <<-DESC
|
8
8
|
This plugin manages the /etc/hosts file for the host and guest machines.
|
9
|
-
An entry is created for each
|
9
|
+
An entry is created for each running machine using the hostname attribute.
|
10
10
|
|
11
11
|
You can also use the hostmanager provisioner to update the hosts file.
|
12
12
|
DESC
|
@@ -24,6 +24,18 @@ module VagrantPlugins
|
|
24
24
|
hook.prepend(Action.update_all)
|
25
25
|
end
|
26
26
|
|
27
|
+
action_hook(:hostmanager, :machine_action_halt) do |hook|
|
28
|
+
hook.prepend(Action.update_all)
|
29
|
+
end
|
30
|
+
|
31
|
+
action_hook(:hostmanager, :machine_action_resume) do |hook|
|
32
|
+
hook.prepend(Action.update_all)
|
33
|
+
end
|
34
|
+
|
35
|
+
action_hook(:hostmanager, :machine_action_suspend) do |hook|
|
36
|
+
hook.prepend(Action.update_all)
|
37
|
+
end
|
38
|
+
|
27
39
|
provisioner(:hostmanager) do
|
28
40
|
require_relative 'provisioner'
|
29
41
|
Provisioner
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hostmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
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-
|
12
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -100,4 +100,3 @@ summary: A Vagrant plugin that manages the /etc/hosts file within a multi-machin
|
|
100
100
|
test_files:
|
101
101
|
- test/Vagrantfile
|
102
102
|
- test/test.sh
|
103
|
-
has_rdoc:
|