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}"
|
||||
node.vm.network "private_network", ip: ip
|
||||
node.vm.hostname = hostname
|
||||
|
||||
# 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.
|
||||
|
|
|
@ -10,16 +10,23 @@ IPAddr.class_eval do
|
|||
end
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestLinux
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
guest_capability("linux", "configure_networks") do
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
end
|
||||
module GuestLinux
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
guest_capability("linux", "change_host_name") do
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability("linux", "configure_networks") do
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestLinux
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
machine.communicate.tap do |comm|
|
||||
interfaces = []
|
||||
|
@ -48,3 +55,19 @@ module VagrantPlugins
|
|||
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