module Vagrant::Util::GuestInspection::Linux

Linux specific inspection helpers

Public Instance Methods

hostnamectl?(comm) click to toggle source

systemd hostname set is via hostnamectl

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @return [Boolean] 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

# File lib/vagrant/util/guest_inspection.rb, line 62
def hostnamectl?(comm)
  comm.test("command -v hostnamectl && hostnamectl")
end
netplan?(comm) click to toggle source

netplan is installed

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @return [Boolean]

# File lib/vagrant/util/guest_inspection.rb, line 72
def netplan?(comm)
  comm.test("command -v netplan")
end
networkd?(comm) click to toggle source

is networkd isntalled

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @return [Boolean]

# File lib/vagrant/util/guest_inspection.rb, line 80
def networkd?(comm)
  comm.test("command -v networkd")
end
nm_controlled?(comm, device_name) click to toggle source

NetworkManager currently controls device

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @param device_name [String] @return [Boolean]

# File lib/vagrant/util/guest_inspection.rb, line 99
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) click to toggle source

nmcli is installed

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @return [Boolean]

# File lib/vagrant/util/guest_inspection.rb, line 90
def nmcli?(comm)
  comm.test("command -v nmcli")
end
systemd?(comm) click to toggle source

systemd is in use

@return [Boolean]

# File lib/vagrant/util/guest_inspection.rb, line 14
def systemd?(comm)
  comm.test("ps -o comm= 1 | grep systemd", sudo: true)
end
systemd_controlled?(comm, service_name) click to toggle source

Check if given service is controlled by systemd

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @param [String] service_name Name of the service to check @return [Boolean]

# 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) click to toggle source

systemd-networkd.service is in use

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @return [Boolean]

# 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) click to toggle source

Check if a unit is currently active within systemd

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @param [String] name Name or pattern to search @return [Boolean]

# 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) click to toggle source

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

@param [Vagrant::Plugin::V2::Communicator] comm Guest communicator @param [String] name Name or pattern to search @return [Boolean]

# 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