vagrant-goodhosts 1.0.13 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9078c31120178731d174a2aa15a12b957d3057e11816127c0f89a319c1c6a400
4
- data.tar.gz: f6fb7224ef9ee4eca57a100eb8cafde6ef684eae61fa9aadbc1160554c6d36f1
3
+ metadata.gz: 86f17cd749321e35fafab21b1187d95010f121ec7ef384341aef7d1e767f66c4
4
+ data.tar.gz: ef74638b070b0ce806b27ae50b3ed05324d5e2715e55c9f26477f77ecead532d
5
5
  SHA512:
6
- metadata.gz: 0456d61e925bbf2dbc232c4adbc3767c36722fd1f4708283201c9a654b5d972828b4cfb8c550d41b937da3fc960243f59d7e9bda8c8b4d5f8365aa1cad1db158
7
- data.tar.gz: 91abd5a594aa8b79a605f9841725f394511907a477bf879a11cb5331d6ded560854cace147e21797c0350afed9aa44a80bae924c4caffc29a161c801b9ae2601
6
+ metadata.gz: b8dc33d45b72b7b6cc29b66d4eb4bf77e73c0e791b54e514905315108aa1d0ce8f1b6d7e3069eda8103f7613fbe1f06200b6c4a0e745b60348f27b78ffef3009
7
+ data.tar.gz: 5d91d96b23d355281840675f3de98a701daaea12e3fec0bf0bd1adf7983c88ecf55e2e3fb8bb39f26da4ebc3643233053cea8bdd8e2b765f6d2512d345eb57ac
data/README.md CHANGED
@@ -30,7 +30,7 @@ You currently only need the `hostname` and a `:private_network` network with a f
30
30
 
31
31
  ```ruby
32
32
  config.vm.network :private_network, ip: "192.168.3.10"
33
- config.vm.hostname = "www.testing.de"
33
+ config.vm.hostname = "www.testing.de" # This is not used by the plugin
34
34
  config.goodhosts.aliases = ["alias.testing.de", "alias2.somedomain.com"]
35
35
  ```
36
36
 
@@ -96,15 +96,15 @@ If you understand the risks that go with supressing them, here's how to do it.
96
96
  ### Linux/OS X: Passwordless sudo
97
97
 
98
98
  To allow vagrant to automatically update the hosts file without asking for a sudo password, add one of the following snippets to a new sudoers file include, i.e. `sudo visudo -f /etc/sudoers.d/vagrant_goodhosts`.
99
- The command path is printed when there are errors with sudo.
99
+ The command path is printed when there are errors with Vagrant, check the output marked in red.
100
100
 
101
101
  For Ubuntu and most Linux environments:
102
102
 
103
- %sudo ALL=(root) NOPASSWD: [the-path]
103
+ %sudo ALL=(root) NOPASSWD: [the-command-path]
104
104
 
105
105
  For MacOS:
106
106
 
107
- %admin ALL=(root) NOPASSWD: [the-path]
107
+ %admin ALL=(root) NOPASSWD: [the-command-path]
108
108
 
109
109
  Replace in both %sudo/%admin with the username it if it is not working for you.
110
110
 
@@ -21,9 +21,15 @@ module VagrantPlugins
21
21
  end
22
22
 
23
23
  def call(env)
24
- if not @@completed.key?(self.class.name)
24
+ # Check whether the plugin has been executed for a particular
25
+ # VM as it may happen that a single Vagrantfile defines multiple
26
+ # machines and having a static flag will result in a plugin being
27
+ # executed just once.
28
+ # https://github.com/goodhosts/vagrant/issues/30
29
+ @@completed[@machine.name] = [] unless @@completed.key?(@machine.name)
30
+ unless @@completed[@machine.name].include? self.class.name
25
31
  run(env)
26
- @@completed[self.class.name] = true
32
+ @@completed[@machine.name] << self.class.name
27
33
  end
28
34
 
29
35
  @app.call(env)
@@ -5,15 +5,15 @@ module VagrantPlugins
5
5
 
6
6
  def run(env)
7
7
  machine_action = env[:machine_action]
8
- if machine_action != :destroy || !@machine.id
9
- if machine_action != :suspend || false != @machine.config.goodhosts.remove_on_suspend
10
- if machine_action != :halt || false != @machine.config.goodhosts.remove_on_suspend
11
- @ui.info "[vagrant-goodhosts] Removing hosts"
12
- removeHostEntries
13
- else
14
- @ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
15
- end
16
- end
8
+
9
+ return unless @machine.id
10
+ return unless [:destroy, :halt, :suspend].include? machine_action
11
+
12
+ if ([:halt, :suspend].include? machine_action) && (false == @machine.config.goodhosts.remove_on_suspend)
13
+ @ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
14
+ else
15
+ @ui.info "[vagrant-goodhosts] Removing hosts"
16
+ removeHostEntries
17
17
  end
18
18
  end
19
19
 
@@ -7,6 +7,11 @@ module VagrantPlugins
7
7
  def getIps
8
8
  ips = []
9
9
 
10
+ if @machine.config.vm.networks.length == 0
11
+ @ui.error("[vagrant-goodhosts] No ip address found for this virtual machine")
12
+ exit
13
+ end
14
+
10
15
  @machine.config.vm.networks.each do |network|
11
16
  key, options = network[0], network[1]
12
17
  ip = options[:ip] if (key == :private_network || key == :public_network) && options[:goodhosts] != "skip"
@@ -111,7 +116,7 @@ module VagrantPlugins
111
116
  if disableClean(ip_address)
112
117
  clean = ''
113
118
  end
114
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo #{cli} add #{clean} #{ip_address} #{hostnames}")
119
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' add #{clean} #{ip_address} #{hostnames}")
115
120
  end
116
121
  if !wait_thr.value.success?
117
122
  error = true
@@ -145,7 +150,7 @@ module VagrantPlugins
145
150
  if disableClean(ip_address)
146
151
  clean = ''
147
152
  end
148
- stdin, stdout, stderr, wait_thr = Open3.popen3("sudo #{cli} remove #{clean} #{ip_address} #{hostnames}")
153
+ stdin, stdout, stderr, wait_thr = Open3.popen3("sudo '#{cli}' remove #{clean} #{ip_address} #{hostnames}")
149
154
  end
150
155
  if !wait_thr.value.success?
151
156
  error = true
@@ -173,13 +178,14 @@ module VagrantPlugins
173
178
  hostnames_by_ips = []
174
179
  ips = getIps
175
180
  if ips.count() < 1
181
+ @ui.error("[vagrant-goodhosts] No ip address found for this virtual machine")
176
182
  return hostnames_by_ips
177
183
  end
178
184
  hostnames = getHostnames(ips)
179
185
  if ips.count() > 1
180
186
  ips.each do |ip|
181
187
  ip_address = ip
182
- if hostnames[ip].count() > 1
188
+ if hostnames[ip].count() > 0
183
189
  hostnames[ip].each do |hostname|
184
190
  if !ip_address.nil?
185
191
  @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
@@ -190,7 +196,7 @@ module VagrantPlugins
190
196
  end
191
197
  else
192
198
  ip_address = ips[0]
193
- if hostnames[ip_address].count() > 1
199
+ if hostnames[ip_address].count() > 0
194
200
  hostnames[ip_address].each do |hostname|
195
201
  if !ip_address.nil?
196
202
  @ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
@@ -9,6 +9,7 @@ module VagrantPlugins
9
9
  attr_accessor :disable_clean
10
10
 
11
11
  def initialize
12
+ @remove_on_suspend = true
12
13
  @disable_clean = true
13
14
  end
14
15
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GoodHosts
3
- VERSION = '1.0.13'
3
+ VERSION = '1.0.17'
4
4
  end
5
5
  end
data/package.sh CHANGED
@@ -13,3 +13,4 @@ rm -f ./*.txt
13
13
  # Generate
14
14
  cd ../../../
15
15
  gem build vagrant-goodhosts.gemspec
16
+ # gem push
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-goodhosts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniele Scasciafratte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-16 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler