vagrant-goodhosts 1.0.8 → 1.0.9
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.
- checksums.yaml +4 -4
- data/.gitignore +21 -2
- data/Gemfile +4 -4
- data/README.md +8 -9
- data/Rakefile +11 -0
- data/lib/vagrant-goodhosts/Action/RemoveHosts.rb +9 -5
- data/lib/vagrant-goodhosts/Action/UpdateHosts.rb +6 -2
- data/lib/vagrant-goodhosts/GoodHosts.rb +25 -14
- data/lib/vagrant-goodhosts/version.rb +1 -1
- data/vagrant-goodhosts.gemspec +17 -16
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 56e892a7cfa68be113df9fb991f5fa52d72e2bc450ead6e1c75b6ef7ad569cb5
|
|
4
|
+
data.tar.gz: 53ee630010bc772f0fc7825e0e4ef25a32973d6d82ac0a6eec75a2854b8ed7dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84e845186cdf8f2458c325cba423ac735c1f1099ac72a9bb86717fa9d199f394159f6a2befe9c76a14eeefcbabf5d39953353f2faedd0d37aec66db092a798da
|
|
7
|
+
data.tar.gz: 407011091f694bbdc4fe85708ec3b11277f2c5be004fb5dfdeccab8eb1d905d0a73bc132f64a8e06653e2ca7ac2af1b699321b0388659e107541a5e7bbbf06a6
|
data/.gitignore
CHANGED
|
@@ -1,16 +1,35 @@
|
|
|
1
|
+
# OS-specific
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
# editors
|
|
5
|
+
*.swp
|
|
6
|
+
|
|
7
|
+
# Bundler/Rubygems
|
|
1
8
|
*.gem
|
|
9
|
+
.bundle
|
|
10
|
+
pkg/*
|
|
11
|
+
tags
|
|
12
|
+
Gemfile.lock
|
|
13
|
+
|
|
14
|
+
# Vagrant
|
|
15
|
+
.vagrant
|
|
16
|
+
Vagrantfile
|
|
17
|
+
!example_box/Vagrantfile
|
|
18
|
+
|
|
19
|
+
# RVM files for gemset/ruby setting
|
|
20
|
+
.ruby-*
|
|
21
|
+
.rvmrc
|
|
22
|
+
|
|
2
23
|
.idea
|
|
3
24
|
*.rbc
|
|
4
25
|
.bundle
|
|
5
26
|
.config
|
|
6
27
|
.yardoc
|
|
7
|
-
Gemfile.lock
|
|
8
28
|
InstalledFiles
|
|
9
29
|
_yardoc
|
|
10
30
|
coverage
|
|
11
31
|
doc/
|
|
12
32
|
lib/bundler/man
|
|
13
|
-
pkg
|
|
14
33
|
rdoc
|
|
15
34
|
spec/reports
|
|
16
35
|
test/tmp
|
data/Gemfile
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
source
|
|
1
|
+
source "https://rubygems.org"
|
|
2
2
|
|
|
3
3
|
group :development do
|
|
4
|
-
gem
|
|
4
|
+
gem "vagrant", git: "https://github.com/hashicorp/vagrant.git"
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
group :plugins do
|
|
8
|
-
|
|
9
|
-
end
|
|
8
|
+
gem "vagrant-goodhosts", path: "."
|
|
9
|
+
end
|
data/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Vagrant::Goodhosts
|
|
2
2
|
|
|
3
|
-
This vagrant plugin adds host file entries to the host pointing to the guest VM, using the [GoodHosts](https://github.com/goodhosts/cli) cli tool. This plugin is based on [vagrant-hostsupdater](https://github.com/cogitatio/vagrant-hostsupdater) and aims to be compatible with the same config parameters.
|
|
3
|
+
This vagrant plugin adds host file entries to the host pointing to the guest VM, using the [GoodHosts](https://github.com/goodhosts/cli) cli tool. This plugin is based on [vagrant-hostsupdater](https://github.com/cogitatio/vagrant-hostsupdater) and aims to be compatible with the same config parameters.
|
|
4
4
|
|
|
5
5
|
On **up**, **resume** and **reload** commands, it tries to add the hosts if they do not already exist in your hosts file. If it needs to be added, you will be asked for the `sudo` password to make the necessary edits.
|
|
6
6
|
|
|
7
|
-
On **halt**, **destroy**, and **suspend**, those entries will be removed again. By setting the `config.goodhosts.remove_on_suspend = false`, **suspend** and **halt** will not remove them.
|
|
7
|
+
On **halt**, **destroy**, and **suspend**, those entries will be removed again. By setting the `config.goodhosts.remove_on_suspend = false`, **suspend** and **halt** will not remove them.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -38,7 +38,7 @@ This IP address and the hostname will be used for the entry in the `/etc/hosts`
|
|
|
38
38
|
|
|
39
39
|
### vagrant-hostsupdater conflicts
|
|
40
40
|
|
|
41
|
-
The original plugin has the issue of be executed in any vagrant environment, also that is not using and will add a rule in the hosts file that is not generated by this one.
|
|
41
|
+
The original plugin has the issue of be executed in any vagrant environment, also that is not using and will add a rule in the hosts file that is not generated by this one.
|
|
42
42
|
To avoid issues is better to remove that plugin and in case update accordingly the Vagrantfile if use it. Require just a change of the reference of the plugin name as the example above.
|
|
43
43
|
|
|
44
44
|
### Multiple private network adapters
|
|
@@ -81,12 +81,12 @@ This disables `vagrant-goodhosts` from running on **suspend** and **halt**.
|
|
|
81
81
|
|
|
82
82
|
## Suppressing prompts for elevating privileges
|
|
83
83
|
|
|
84
|
-
These prompts exist to prevent anything that is being run by the user from inadvertently updating the hosts file.
|
|
84
|
+
These prompts exist to prevent anything that is being run by the user from inadvertently updating the hosts file.
|
|
85
85
|
If you understand the risks that go with supressing them, here's how to do it.
|
|
86
86
|
|
|
87
87
|
### Linux/OS X: Passwordless sudo
|
|
88
88
|
|
|
89
|
-
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`.
|
|
89
|
+
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`.
|
|
90
90
|
The command path is printed when there are errors with sudo.
|
|
91
91
|
|
|
92
92
|
For Ubuntu and most Linux environments:
|
|
@@ -96,15 +96,15 @@ For Ubuntu and most Linux environments:
|
|
|
96
96
|
For MacOS:
|
|
97
97
|
|
|
98
98
|
%admin ALL=(root) NOPASSWD: [the-path]
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
Replace in both %sudo/%admin with the username it if it is not working for you.
|
|
101
101
|
|
|
102
102
|
### Windows: UAC Prompt
|
|
103
103
|
|
|
104
|
-
You can use `cacls` or `icacls` to grant your user account permanent write permission to the system's hosts file.
|
|
104
|
+
You can use `cacls` or `icacls` to grant your user account permanent write permission to the system's hosts file.
|
|
105
105
|
You have to open an elevated command prompt; hold `❖ Win` and press `X`, then choose "Command Prompt (Admin)"
|
|
106
106
|
|
|
107
|
-
cacls %SYSTEMROOT%\system32\drivers\etc\hosts /E /G %USERNAME%:W
|
|
107
|
+
cacls %SYSTEMROOT%\system32\drivers\etc\hosts /E /G %USERNAME%:W
|
|
108
108
|
|
|
109
109
|
## Installing The Development Version
|
|
110
110
|
|
|
@@ -113,7 +113,6 @@ If you would like to install `vagrant-goodhosts` to make contributions or change
|
|
|
113
113
|
```shell
|
|
114
114
|
git clone https://github.com/goodhosts/vagrant vagrant-goodhosts
|
|
115
115
|
cd vagrant-goodhosts
|
|
116
|
-
git checkout develop
|
|
117
116
|
./package.sh
|
|
118
117
|
vagrant plugin install vagrant-goodhosts-*.gem
|
|
119
118
|
```
|
data/Rakefile
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
# Immediately sync all stdout so that tools like buildbot can
|
|
5
|
+
# immediately load in the output.
|
|
6
|
+
$stdout.sync = true
|
|
7
|
+
$stderr.sync = true
|
|
8
|
+
|
|
9
|
+
# Change to the directory of this file.
|
|
10
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
|
11
|
+
|
|
12
|
+
# This installs the tasks that help with gem creation and
|
|
13
|
+
# publishing.
|
|
3
14
|
Bundler::GemHelper.install_tasks
|
|
@@ -3,6 +3,7 @@ module VagrantPlugins
|
|
|
3
3
|
module Action
|
|
4
4
|
class RemoveHosts
|
|
5
5
|
include GoodHosts
|
|
6
|
+
@@updated = false
|
|
6
7
|
|
|
7
8
|
def initialize(app, env)
|
|
8
9
|
@app = app
|
|
@@ -14,11 +15,14 @@ module VagrantPlugins
|
|
|
14
15
|
machine_action = env[:machine_action]
|
|
15
16
|
if machine_action != :destroy || !@machine.id
|
|
16
17
|
if machine_action != :suspend || false != @machine.config.goodhosts.remove_on_suspend
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
unless @@updated
|
|
19
|
+
@@updated = true
|
|
20
|
+
if machine_action != :halt || false != @machine.config.goodhosts.remove_on_suspend
|
|
21
|
+
@ui.info "[vagrant-goodhosts] Removing hosts"
|
|
22
|
+
removeHostEntries
|
|
23
|
+
else
|
|
24
|
+
@ui.info "[vagrant-goodhosts] Removing hosts on suspend disabled"
|
|
25
|
+
end
|
|
22
26
|
end
|
|
23
27
|
end
|
|
24
28
|
end
|
|
@@ -4,6 +4,7 @@ module VagrantPlugins
|
|
|
4
4
|
module Action
|
|
5
5
|
class UpdateHosts
|
|
6
6
|
include GoodHosts
|
|
7
|
+
@@updated = false
|
|
7
8
|
|
|
8
9
|
def initialize(app, env)
|
|
9
10
|
@app = app
|
|
@@ -12,8 +13,11 @@ module VagrantPlugins
|
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def call(env)
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
unless @@updated
|
|
17
|
+
@@updated = true
|
|
18
|
+
@ui.info "[vagrant-goodhosts] Checking for host entries"
|
|
19
|
+
addHostEntries()
|
|
20
|
+
end
|
|
17
21
|
@app.call(env)
|
|
18
22
|
end
|
|
19
23
|
|
|
@@ -5,10 +5,6 @@ module VagrantPlugins
|
|
|
5
5
|
module GoodHosts
|
|
6
6
|
module GoodHosts
|
|
7
7
|
def getIps
|
|
8
|
-
if Vagrant.has_plugin?("vagrant-hostsupdater")
|
|
9
|
-
@ui.warn "[vagrant-goodhosts] Warning: The vagrant-hostsupdater plugin is installed, hostsupdater always adds the VM name even if the VagrantFile says not to. This shouldn't cause issues, but if it does, uninstall hostsupdater"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
8
|
ips = []
|
|
13
9
|
|
|
14
10
|
@machine.config.vm.networks.each do |network|
|
|
@@ -16,7 +12,7 @@ module VagrantPlugins
|
|
|
16
12
|
ip = options[:ip] if (key == :private_network || key == :public_network) && options[:goodhosts] != "skip"
|
|
17
13
|
ips.push(ip) if ip
|
|
18
14
|
if options[:goodhosts] == "skip"
|
|
19
|
-
@ui.info '[vagrant-goodhosts]
|
|
15
|
+
@ui.info '[vagrant-goodhosts] Skipped adding host entries (config.vm.network goodhosts: "skip" is set)'
|
|
20
16
|
end
|
|
21
17
|
|
|
22
18
|
@machine.config.vm.provider :hyperv do |v|
|
|
@@ -36,7 +32,7 @@ module VagrantPlugins
|
|
|
36
32
|
end
|
|
37
33
|
end
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
|
|
40
36
|
end
|
|
41
37
|
return ips
|
|
42
38
|
end
|
|
@@ -89,7 +85,11 @@ module VagrantPlugins
|
|
|
89
85
|
errorText = ""
|
|
90
86
|
cli = get_cli
|
|
91
87
|
hostnames_by_ips = generateHostnamesByIps
|
|
88
|
+
|
|
89
|
+
return if hostnames_by_ips.empty?
|
|
90
|
+
|
|
92
91
|
hostnames_by_ips.each do |ip_address, hostnames|
|
|
92
|
+
next if hostnames.empty?
|
|
93
93
|
if ip_address.nil?
|
|
94
94
|
@ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
|
|
95
95
|
next
|
|
@@ -112,7 +112,11 @@ module VagrantPlugins
|
|
|
112
112
|
errorText = ""
|
|
113
113
|
cli = get_cli
|
|
114
114
|
hostnames_by_ips = generateHostnamesByIps
|
|
115
|
+
|
|
116
|
+
return if hostnames_by_ips.empty?
|
|
117
|
+
|
|
115
118
|
hostnames_by_ips.each do |ip_address, hostnames|
|
|
119
|
+
next if hostnames.empty?
|
|
116
120
|
if ip_address.nil?
|
|
117
121
|
@ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
|
|
118
122
|
next
|
|
@@ -147,25 +151,32 @@ module VagrantPlugins
|
|
|
147
151
|
def generateHostnamesByIps()
|
|
148
152
|
hostnames_by_ips = []
|
|
149
153
|
ips = getIps
|
|
154
|
+
if ips.count() < 1
|
|
155
|
+
return hostnames_by_ips
|
|
156
|
+
end
|
|
150
157
|
hostnames = getHostnames(ips)
|
|
151
158
|
if ips.count() > 1
|
|
152
159
|
ips.each do |ip|
|
|
153
160
|
ip_address = ip
|
|
154
|
-
hostnames[ip].
|
|
155
|
-
|
|
156
|
-
|
|
161
|
+
if hostnames[ip].count() > 1
|
|
162
|
+
hostnames[ip].each do |hostname|
|
|
163
|
+
if !ip_address.nil?
|
|
164
|
+
@ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
|
|
165
|
+
end
|
|
157
166
|
end
|
|
167
|
+
hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
|
|
158
168
|
end
|
|
159
|
-
hostnames_by_ips = { ip_address => hostnames[ip].join(" ") }
|
|
160
169
|
end
|
|
161
170
|
else
|
|
162
171
|
ip_address = ips[0]
|
|
163
|
-
hostnames[ip_address].
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
if hostnames[ip_address].count() > 1
|
|
173
|
+
hostnames[ip_address].each do |hostname|
|
|
174
|
+
if !ip_address.nil?
|
|
175
|
+
@ui.info "[vagrant-goodhosts] - found entry for: #{ip_address} #{hostname}"
|
|
176
|
+
end
|
|
166
177
|
end
|
|
178
|
+
hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
|
|
167
179
|
end
|
|
168
|
-
hostnames_by_ips = { ip_address => hostnames[ip_address].join(" ") }
|
|
169
180
|
end
|
|
170
181
|
|
|
171
182
|
return hostnames_by_ips
|
data/vagrant-goodhosts.gemspec
CHANGED
|
@@ -3,22 +3,23 @@ lib = File.expand_path('../lib', __FILE__)
|
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'vagrant-goodhosts/version'
|
|
5
5
|
|
|
6
|
-
Gem::Specification.new do |
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'vagrant-goodhosts'
|
|
8
|
+
s.version = VagrantPlugins::GoodHosts::VERSION
|
|
9
|
+
s.platform = Gem::Platform::RUBY
|
|
10
|
+
s.authors = ['Daniele Scasciafratte']
|
|
11
|
+
s.email = ['mte90net@gmail.com']
|
|
12
|
+
s.description = "Enables Vagrant to update hosts file on the host machine with goodhosts"
|
|
13
|
+
s.summary = s.description
|
|
14
|
+
s.homepage = 'https://github.com/goodhosts/vagrant'
|
|
15
|
+
s.license = 'MIT'
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
s.files = `git ls-files`.split($/)
|
|
18
|
+
s.files += Dir.glob("lib/vagrant-goodhosts/bundle/*")
|
|
19
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
21
|
+
s.require_paths = ['lib']
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
s.add_development_dependency 'bundler', '~> 1.3'
|
|
24
|
+
s.add_development_dependency 'rake'
|
|
24
25
|
end
|
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.
|
|
4
|
+
version: 1.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniele Scasciafratte
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-12-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
requirements: []
|
|
84
|
-
rubygems_version: 3.2.0.rc.
|
|
84
|
+
rubygems_version: 3.2.0.rc.2
|
|
85
85
|
signing_key:
|
|
86
86
|
specification_version: 4
|
|
87
87
|
summary: Enables Vagrant to update hosts file on the host machine with goodhosts
|