Class: VagrantPlugins::GuestRedHat::Cap::ChangeHostName
- Inherits:
-
Object
- Object
- VagrantPlugins::GuestRedHat::Cap::ChangeHostName
- Defined in:
- lib/vagrant-patches/issue-4465.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.change_host_name(machine, name) ⇒ Object
9 10 11 |
# File 'lib/vagrant-patches/issue-4465.rb', line 9 def self.change_host_name(machine, name) new(machine, name).change! end |
Instance Method Details
#change! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-patches/issue-4465.rb', line 13 def change! return unless should_change? case machine.guest.capability("flavor") when :rhel_7 update_hostname_rhel7 update_etc_hosts else update_sysconfig update_hostname update_etc_hosts update_dhcp_hostnames restart_networking end end |
#should_change? ⇒ Boolean
29 30 31 |
# File 'lib/vagrant-patches/issue-4465.rb', line 29 def should_change? new_hostname != current_hostname end |
#update_hostname_rhel7 ⇒ Object
33 34 35 |
# File 'lib/vagrant-patches/issue-4465.rb', line 33 def update_hostname_rhel7 sudo "hostnamectl set-hostname #{fqdn}" end |