vagrant-hosts 1.0.0 → 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/CHANGELOG +16 -0
- data/lib/vagrant-hosts.rb +3 -1
- data/lib/vagrant-hosts/plugin.rb +3 -2
- data/lib/vagrant-hosts/provisioner.rb +10 -4
- data/lib/vagrant-hosts/provisioner/hostname.rb +26 -0
- data/lib/vagrant-hosts/version.rb +1 -1
- metadata +4 -2
data/CHANGELOG
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
=========
|
3
|
+
|
4
|
+
1.1.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
This is a backwards compatible feature and bugfix release.
|
8
|
+
|
9
|
+
* Support Vagrant 1.2 change_host_name capability
|
10
|
+
* Support Vagrant 1.1 and 1.2 change_host_name invocation
|
11
|
+
* Add config.vm.hostname into hosts file if set
|
12
|
+
|
13
|
+
Thanks to the following contributors:
|
14
|
+
|
15
|
+
- Patrick Otto
|
16
|
+
- Luke Amdor
|
data/lib/vagrant-hosts.rb
CHANGED
data/lib/vagrant-hosts/plugin.rb
CHANGED
@@ -2,8 +2,9 @@ require 'vagrant'
|
|
2
2
|
require 'vagrant-hosts'
|
3
3
|
require 'vagrant-hosts/version'
|
4
4
|
|
5
|
-
if Vagrant::VERSION <
|
6
|
-
raise "vagrant-hosts version #{VagrantHosts::VERSION} requires Vagrant
|
5
|
+
if Vagrant::VERSION < VagrantHosts::REQUIRED_VAGRANT_VERSION
|
6
|
+
raise "vagrant-hosts version #{VagrantHosts::VERSION} requires Vagrant " +
|
7
|
+
"#{VagrantHosts::REQUIRED_VAGRANT_VERSION} or later"
|
7
8
|
end
|
8
9
|
|
9
10
|
class VagrantHosts::Plugin < Vagrant.plugin(2)
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'vagrant'
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
-
|
5
4
|
module VagrantHosts
|
6
5
|
class Provisioner < Vagrant.plugin('2', :provisioner)
|
7
6
|
|
8
7
|
def initialize(machine, config)
|
9
8
|
@machine, @config = machine, config
|
10
|
-
p
|
11
9
|
end
|
12
10
|
|
13
11
|
def provision
|
@@ -20,6 +18,12 @@ class Provisioner < Vagrant.plugin('2', :provisioner)
|
|
20
18
|
|
21
19
|
class Linux
|
22
20
|
|
21
|
+
# This has to be inside of this class, because otherwise the hostname mixin
|
22
|
+
# will create this class with a different superclass. It makes me sad. :(
|
23
|
+
require 'vagrant-hosts/provisioner/hostname'
|
24
|
+
include VagrantHosts::Provisioner::Hostname
|
25
|
+
|
26
|
+
|
23
27
|
def initialize(machine, config)
|
24
28
|
@machine, @config = machine, config
|
25
29
|
end
|
@@ -39,7 +43,8 @@ class Provisioner < Vagrant.plugin('2', :provisioner)
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def update_hosts
|
42
|
-
@machine.
|
46
|
+
hostname = @machine.config.vm.hostname || @machine.name.to_s
|
47
|
+
change_host_name(hostname)
|
43
48
|
@machine.communicate.sudo('install -m 644 /tmp/hosts /etc/hosts')
|
44
49
|
end
|
45
50
|
|
@@ -75,10 +80,11 @@ class Provisioner < Vagrant.plugin('2', :provisioner)
|
|
75
80
|
|
76
81
|
names.each do |name|
|
77
82
|
network_settings = env.machine(name, :virtualbox).config.vm.networks
|
83
|
+
hostname = env.machine(name, :virtualbox).config.vm.hostname
|
78
84
|
network_settings.each do |entry|
|
79
85
|
if entry[0] == :private_network
|
80
86
|
ipaddr = entry[1][:ip]
|
81
|
-
hosts << [ipaddr, [name]]
|
87
|
+
hosts << [ipaddr, [hostname, name]]
|
82
88
|
end
|
83
89
|
end
|
84
90
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require 'vagrant-hosts/provisioner'
|
3
|
+
|
4
|
+
module VagrantHosts
|
5
|
+
class Provisioner
|
6
|
+
module Hostname
|
7
|
+
# Abstract the details of setting a guest hostname on different versions of
|
8
|
+
# Vagrant.
|
9
|
+
#
|
10
|
+
# Vagrant commit 61d2f9f96fc0f0ef5869c732674f25c4ccc85c8c converts the
|
11
|
+
# #change_host_name # method to a capability, which breaks the API between
|
12
|
+
# 1.1 and 1.2. :(
|
13
|
+
|
14
|
+
# @param name [String] The new hostname to apply on the guest
|
15
|
+
def change_host_name(name)
|
16
|
+
case Vagrant::VERSION
|
17
|
+
when /1\.1/
|
18
|
+
@machine.guest.change_host_name(name)
|
19
|
+
when /1\.2/
|
20
|
+
@machine.guest.capability(:change_host_name, name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
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-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vagrant
|
@@ -35,12 +35,14 @@ executables: []
|
|
35
35
|
extensions: []
|
36
36
|
extra_rdoc_files: []
|
37
37
|
files:
|
38
|
+
- CHANGELOG
|
38
39
|
- LICENSE
|
39
40
|
- README.markdown
|
40
41
|
- lib/vagrant-hosts.rb
|
41
42
|
- lib/vagrant-hosts/config.rb
|
42
43
|
- lib/vagrant-hosts/plugin.rb
|
43
44
|
- lib/vagrant-hosts/provisioner.rb
|
45
|
+
- lib/vagrant-hosts/provisioner/hostname.rb
|
44
46
|
- lib/vagrant-hosts/version.rb
|
45
47
|
- vagrant-hosts.gemspec
|
46
48
|
homepage: https://github.com/adrienthebo/vagrant-hosts
|