Use hostnamectl to set the hostname on Ubuntu Vivid 15.
This commit is contained in:
parent
b421af58e8
commit
67cde0d9b9
|
@ -6,22 +6,39 @@ module VagrantPlugins
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_etc_hostname
|
||||||
|
super unless vivid?
|
||||||
|
sudo("hostnamectl set-hostname '#{short_hostname}'")
|
||||||
|
end
|
||||||
|
|
||||||
def refresh_hostname_service
|
def refresh_hostname_service
|
||||||
if hardy?
|
if hardy?
|
||||||
# hostname.sh returns 1, so use `true` to get a 0 exitcode
|
# hostname.sh returns 1, so use `true` to get a 0 exitcode
|
||||||
sudo("/etc/init.d/hostname.sh start; true")
|
sudo("/etc/init.d/hostname.sh start; true")
|
||||||
|
elsif vivid?
|
||||||
|
# Service runs via hostnamectl
|
||||||
else
|
else
|
||||||
sudo("service hostname start")
|
sudo("service hostname start")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def hardy?
|
def hardy?
|
||||||
machine.communicate.test("[ `lsb_release -c -s` = hardy ]")
|
os_version("hardy")
|
||||||
|
end
|
||||||
|
|
||||||
|
def vivid?
|
||||||
|
os_version("vivid")
|
||||||
end
|
end
|
||||||
|
|
||||||
def renew_dhcp
|
def renew_dhcp
|
||||||
sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug")
|
sudo("ifdown -a; ifup -a; ifup -a --allow=hotplug")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def os_version(name)
|
||||||
|
machine.communicate.test("[ `lsb_release -c -s` = #{name} ]")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue