Module: Vagrant::Util::GuestInspection::Linux

Defined in:
lib/vagrant/util/guest_inspection.rb

Overview

Linux specific inspection helpers

Instance Method Summary collapse

Instance Method Details

#hostnamectl?(comm) ⇒ Boolean

systemd hostname set is via hostnamectl

NOTE: This test includes actually calling hostnamectl to verify that it is in working order. This prevents attempts to use the hostnamectl command when it is available, but dbus is not which renders the command useless

Parameters:

Returns:

  • (Boolean)


62
63
64
# File 'lib/vagrant/util/guest_inspection.rb', line 62

def hostnamectl?(comm)
  comm.test("command -v hostnamectl && hostnamectl")
end

#netplan?(comm) ⇒ Boolean

netplan is installed

Parameters:

Returns:

  • (Boolean)


72
73
74
# File 'lib/vagrant/util/guest_inspection.rb', line 72

def netplan?(comm)
  comm.test("command -v netplan")
end

#nm_controlled?(comm, device_name) ⇒ Boolean

NetworkManager currently controls device

Parameters:

Returns:

  • (Boolean)


91
92
93
94
# File 'lib/vagrant/util/guest_inspection.rb', line 91

def nm_controlled?(comm, device_name)
  comm.test("nmcli -t d show #{device_name}") &&
    !comm.test("nmcli -t d show #{device_name} | grep unmanaged")
end

#nmcli?(comm) ⇒ Boolean

nmcli is installed

Parameters:

Returns:

  • (Boolean)


82
83
84
# File 'lib/vagrant/util/guest_inspection.rb', line 82

def nmcli?(comm)
  comm.test("command -v nmcli")
end

#systemd?(comm) ⇒ Boolean

systemd is in use

Returns:

  • (Boolean)


14
15
16
# File 'lib/vagrant/util/guest_inspection.rb', line 14

def systemd?(comm)
  comm.test("ps -o comm= 1 | grep systemd")
end

#systemd_controlled?(comm, service_name) ⇒ Boolean

Check if given service is controlled by systemd

Parameters:

Returns:

  • (Boolean)


50
51
52
# File 'lib/vagrant/util/guest_inspection.rb', line 50

def systemd_controlled?(comm, service_name)
  comm.test("systemctl -q is-active #{service_name}", sudo: true)
end

#systemd_networkd?(comm) ⇒ Boolean

systemd-networkd.service is in use

Parameters:

Returns:

  • (Boolean)


22
23
24
# File 'lib/vagrant/util/guest_inspection.rb', line 22

def systemd_networkd?(comm)
  comm.test("systemctl -q is-active systemd-networkd.service", sudo: true)
end

#systemd_unit?(comm, name) ⇒ Boolean

Check if a unit is currently active within systemd

Parameters:

Returns:

  • (Boolean)


41
42
43
# File 'lib/vagrant/util/guest_inspection.rb', line 41

def systemd_unit?(comm, name)
  comm.test("systemctl -q list-units | grep \"#{name}\"")
end

#systemd_unit_file?(comm, name) ⇒ Boolean

Check if a unit file with the given name is defined. Name can be a pattern or explicit name.

Parameters:

Returns:

  • (Boolean)


32
33
34
# File 'lib/vagrant/util/guest_inspection.rb', line 32

def systemd_unit_file?(comm, name)
  comm.test("systemctl -q list-unit-files | grep \"#{name}\"")
end