Module: Vagrant::Util::GuestInspection::Linux
- Defined in:
- lib/vagrant/util/guest_inspection.rb
Overview
Linux specific inspection helpers
Instance Method Summary collapse
-
#hostnamectl?(comm) ⇒ Boolean
systemd hostname set is via hostnamectl.
-
#netplan?(comm) ⇒ Boolean
netplan is installed.
-
#networkd?(comm) ⇒ Boolean
is networkd isntalled.
-
#nm_controlled?(comm, device_name) ⇒ Boolean
NetworkManager currently controls device.
-
#nmcli?(comm) ⇒ Boolean
nmcli is installed.
-
#systemd?(comm) ⇒ Boolean
systemd is in use.
-
#systemd_controlled?(comm, service_name) ⇒ Boolean
Check if given service is controlled by systemd.
-
#systemd_networkd?(comm) ⇒ Boolean
systemd-networkd.service is in use.
-
#systemd_unit?(comm, name) ⇒ Boolean
Check if a unit is currently active within systemd.
-
#systemd_unit_file?(comm, name) ⇒ Boolean
Check if a unit file with the given name is defined.
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
65 66 67 |
# File 'lib/vagrant/util/guest_inspection.rb', line 65 def hostnamectl?(comm) comm.test("command -v hostnamectl && hostnamectl") end |
#netplan?(comm) ⇒ Boolean
netplan is installed
75 76 77 |
# File 'lib/vagrant/util/guest_inspection.rb', line 75 def netplan?(comm) comm.test("command -v netplan") end |
#networkd?(comm) ⇒ Boolean
is networkd isntalled
83 84 85 |
# File 'lib/vagrant/util/guest_inspection.rb', line 83 def networkd?(comm) comm.test("command -v networkd") end |
#nm_controlled?(comm, device_name) ⇒ Boolean
NetworkManager currently controls device
102 103 104 105 |
# File 'lib/vagrant/util/guest_inspection.rb', line 102 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
93 94 95 |
# File 'lib/vagrant/util/guest_inspection.rb', line 93 def nmcli?(comm) comm.test("command -v nmcli") end |
#systemd?(comm) ⇒ Boolean
systemd is in use
17 18 19 |
# File 'lib/vagrant/util/guest_inspection.rb', line 17 def systemd?(comm) comm.test("ps -o comm= 1 | grep systemd", sudo: true) end |
#systemd_controlled?(comm, service_name) ⇒ Boolean
Check if given service is controlled by systemd
53 54 55 |
# File 'lib/vagrant/util/guest_inspection.rb', line 53 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
25 26 27 |
# File 'lib/vagrant/util/guest_inspection.rb', line 25 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
44 45 46 |
# File 'lib/vagrant/util/guest_inspection.rb', line 44 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.
35 36 37 |
# File 'lib/vagrant/util/guest_inspection.rb', line 35 def systemd_unit_file?(comm, name) comm.test("systemctl -q list-unit-files | grep \"#{name}\"") end |