vagrant-hostmanager 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -14,17 +14,29 @@ module VagrantPlugins
|
|
14
14
|
# upload modified file and remove temporary file
|
15
15
|
machine.communicate.upload(file, '/tmp/hosts')
|
16
16
|
machine.communicate.sudo('mv /tmp/hosts /etc/hosts')
|
17
|
-
|
17
|
+
# i have no idea if this is a windows competibility issue or not, but sometimes it dosen't work on my machine
|
18
|
+
begin
|
19
|
+
FileUtils.rm(file)
|
20
|
+
rescue Exception => e
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
24
|
def update_host
|
21
25
|
# copy and modify hosts file on host with Vagrant-managed entries
|
22
26
|
file = @global_env.tmp_path.join('hosts.local')
|
23
|
-
|
27
|
+
# add a "if windows..."
|
28
|
+
hosts_location = '/etc/hosts'
|
29
|
+
copy_cmd = 'sudo cp'
|
30
|
+
# handles the windows hosts file...
|
31
|
+
if ENV['OS'] == 'Windows_NT'
|
32
|
+
hosts_location = "#{ENV['WINDIR']}\\System32\\drivers\\etc\\hosts"
|
33
|
+
copy_cmd = 'cp'
|
34
|
+
end
|
35
|
+
FileUtils.cp(hosts_location, file)
|
24
36
|
update_file(file)
|
25
37
|
|
26
38
|
# copy modified file using sudo for permission
|
27
|
-
|
39
|
+
`#{copy_cmd} #{file} #{hosts_location}`
|
28
40
|
end
|
29
41
|
|
30
42
|
private
|
@@ -32,6 +44,7 @@ module VagrantPlugins
|
|
32
44
|
def update_file(file)
|
33
45
|
# build array of host file entries from Vagrant configuration
|
34
46
|
entries = []
|
47
|
+
ids = []
|
35
48
|
get_machines.each do |name, p|
|
36
49
|
if @provider == p
|
37
50
|
machine = @global_env.machine(name, p)
|
@@ -40,6 +53,7 @@ module VagrantPlugins
|
|
40
53
|
ip = get_ip_address(machine)
|
41
54
|
aliases = machine.config.hostmanager.aliases.join(' ').chomp
|
42
55
|
entries << "#{ip}\t#{host} #{aliases}\t# VAGRANT ID: #{id}\n"
|
56
|
+
ids << id unless ids.include?(id)
|
43
57
|
end
|
44
58
|
end
|
45
59
|
|
@@ -47,7 +61,7 @@ module VagrantPlugins
|
|
47
61
|
begin
|
48
62
|
# copy each line not managed by Vagrant
|
49
63
|
File.open(file).each_line do |line|
|
50
|
-
tmp_file << line unless line =~ /# VAGRANT ID
|
64
|
+
tmp_file << line unless ids.any? { |id| line =~ /# VAGRANT ID: #{id}/ }
|
51
65
|
end
|
52
66
|
|
53
67
|
# write a line for each Vagrant-managed entry
|
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '1.3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: A Vagrant plugin that manages the /etc/hosts file within a multi-machine
|
37
47
|
environment
|
38
48
|
email:
|
@@ -82,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
92
|
version: '0'
|
83
93
|
requirements: []
|
84
94
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.8.
|
95
|
+
rubygems_version: 1.8.23
|
86
96
|
signing_key:
|
87
97
|
specification_version: 3
|
88
98
|
summary: A Vagrant plugin that manages the /etc/hosts file within a multi-machine
|