Added Hostname capability
This commit is contained in:
parent
2f338aafe1
commit
a0ec46a987
|
@ -29,6 +29,7 @@ Vagrant.configure(2) do |config|
|
||||||
|
|
||||||
ip = "172.19.8.#{i+100}"
|
ip = "172.19.8.#{i+100}"
|
||||||
node.vm.network "private_network", ip: ip
|
node.vm.network "private_network", ip: ip
|
||||||
|
node.vm.hostname = hostname
|
||||||
|
|
||||||
# Disabling compression because OS X has an ancient version of rsync installed.
|
# Disabling compression because OS X has an ancient version of rsync installed.
|
||||||
# Add -z or remove rsync__args below if you have a newer version of rsync on your machine.
|
# Add -z or remove rsync__args below if you have a newer version of rsync on your machine.
|
||||||
|
|
|
@ -12,14 +12,21 @@ end
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module GuestLinux
|
module GuestLinux
|
||||||
class Plugin < Vagrant.plugin("2")
|
class Plugin < Vagrant.plugin("2")
|
||||||
|
guest_capability("linux", "change_host_name") do
|
||||||
|
Cap::ChangeHostName
|
||||||
|
end
|
||||||
|
|
||||||
guest_capability("linux", "configure_networks") do
|
guest_capability("linux", "configure_networks") do
|
||||||
Cap::ConfigureNetworks
|
Cap::ConfigureNetworks
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestLinux
|
||||||
module Cap
|
module Cap
|
||||||
class ConfigureNetworks
|
class ConfigureNetworks
|
||||||
|
|
||||||
def self.configure_networks(machine, networks)
|
def self.configure_networks(machine, networks)
|
||||||
machine.communicate.tap do |comm|
|
machine.communicate.tap do |comm|
|
||||||
interfaces = []
|
interfaces = []
|
||||||
|
@ -48,3 +55,19 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestLinux
|
||||||
|
module Cap
|
||||||
|
class ChangeHostName
|
||||||
|
def self.change_host_name(machine, name)
|
||||||
|
machine.communicate.tap do |comm|
|
||||||
|
if !comm.test("sudo hostname --fqdn | grep '#{name}'")
|
||||||
|
comm.sudo("hostname #{name.split('.')[0]}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue