vagrant-hostsupdater 0.0.2 → 0.0.3
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 +5 -5
- data/README.md +17 -9
- data/lib/vagrant-hostsupdater/HostsUpdater.rb +17 -4
- data/lib/vagrant-hostsupdater/config.rb +1 -3
- data/lib/vagrant-hostsupdater/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
data.tar.gz: 41d5f5dda99247f31cdfca83d319b2efc2dc5673fba3ed70b689da8eb509856a73b20f73945becd9a87749fe89548364d31ecd7b3e705f5e3f42bfc26e8f9c7e
|
4
|
-
metadata.gz: fbdae7cc3bff2600a7655198c1d8220009db57d54b0951b35dce7d30e4edc1bbf4a22bd4221c6432e58b989e46130ff2017e01a374e84ca92ab3258312201887
|
5
2
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 6663b44949ad00cfb53164de9cc616c6cf08003c
|
4
|
+
metadata.gz: d28529fec2edd9b8777ff9e76f13b911967b8d53
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: a0ebcf97535835ab90809366426e709a9498a86a79aee3552a02655df423fb918b2ed69fde2bb6d5c2e427912c6f9c4846980e5fce257a0b20ab13e02b5d26da
|
7
|
+
metadata.gz: 9243d172905732d62f823acbca185986f1b3cc4daa4a6a100503854d60af6fad2c8d475171b936d579f9ba5112b7f46ac829aaded6eda2e0fa4733f1ffe5ff1a
|
data/README.md
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
# Vagrant::Hostsupdater
|
2
2
|
|
3
|
-
|
3
|
+
This plugin adds an entry to your /etc/hosts file on the host system.
|
4
4
|
|
5
|
-
|
5
|
+
On **up** and **reload** commands, it tries to add the information, if its not already existant in your hosts file. If it needs to be added, you will be asked for an administrator password, since it uses sudo to edit the file.
|
6
6
|
|
7
|
-
|
7
|
+
On **halt**, **suspend** and **destroy**, those entries will be removed again.
|
8
8
|
|
9
|
-
|
9
|
+
## Versions
|
10
|
+
### 0.0.3
|
11
|
+
* added aliases config option to define additional hostnames
|
10
12
|
|
11
|
-
|
13
|
+
## Installation
|
12
14
|
|
13
|
-
$
|
15
|
+
$ vagrant plugin install vagrant-hostsupdater
|
14
16
|
|
15
|
-
|
17
|
+
Uninstall it with:
|
16
18
|
|
17
|
-
$
|
19
|
+
$ vagrant plugin uninstall vagrant-hostsupdater
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
At the moment, the only things you need, are the hostname and a :private_network network with a fixed ip.
|
24
|
+
|
25
|
+
$ config.vm.network :private_network, ip: "192.168.3.10"
|
26
|
+
$ config.vm.hostname = "www.testing.de"
|
27
|
+
$ config.hostsupdater.aliases = ["alias.testing.de", "alias2.somedomain.com"]
|
28
|
+
|
29
|
+
This ip and the hostname will be used for the entry in the /etc/hosts file.
|
22
30
|
|
23
31
|
## Contributing
|
24
32
|
|
@@ -17,6 +17,9 @@ module VagrantPlugins
|
|
17
17
|
|
18
18
|
def getHostnames
|
19
19
|
hostnames = Array(@machine.config.vm.hostname)
|
20
|
+
if @machine.config.hostsupdater.aliases
|
21
|
+
hostnames.concat(@machine.config.hostsupdater.aliases)
|
22
|
+
end
|
20
23
|
return hostnames
|
21
24
|
end
|
22
25
|
|
@@ -29,10 +32,12 @@ module VagrantPlugins
|
|
29
32
|
name = @machine.name
|
30
33
|
entries = []
|
31
34
|
ips.each do |ip|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
hostEntries = getHostEntries(ip, hostnames, name, uuid)
|
36
|
+
hostEntries.each do |hostEntry|
|
37
|
+
escapedEntry = Regexp.quote(hostEntry)
|
38
|
+
if !hostsContents.match(/#{escapedEntry}/)
|
39
|
+
entries.push(hostEntry)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
sudo(addToHosts(entries))
|
@@ -57,6 +62,14 @@ module VagrantPlugins
|
|
57
62
|
%Q(#{ip} #{hostnames.join(' ')} #{signature(name, uuid)})
|
58
63
|
end
|
59
64
|
|
65
|
+
def getHostEntries(ip, hostnames, name, uuid = self.uuid)
|
66
|
+
entries = []
|
67
|
+
hostnames.each do |hostname|
|
68
|
+
entries.push(%Q(#{ip} #{hostname} #{signature(name, uuid)}))
|
69
|
+
end
|
70
|
+
return entries
|
71
|
+
end
|
72
|
+
|
60
73
|
def addToHosts(entries)
|
61
74
|
return if entries.length == 0
|
62
75
|
hosts_path = '/etc/hosts'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hostsupdater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Falk Ku\xCC\x88hnel"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-01 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|