Class: VagrantPlugins::GuestPhoton::Cap::ChangeHostName

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-guests-photon/cap/change_host_name.rb

Class Method Summary collapse

Class Method Details

.change_host_name(machine, name) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/vagrant-guests-photon/cap/change_host_name.rb', line 8

def self.change_host_name(machine, name)
  machine.communicate.tap do |comm|
    unless comm.test("hostnamectl --static | grep '#{name}'")
      comm.sudo("rm /etc/machine-id")
      comm.sudo("systemd-machine-id-setup")
      comm.sudo("hostnamectl set-hostname #{name.split('.')[0]}")
    end
  end
end