vaguerent/lib/vagrant/util/guest_inspection.rb
Simon Baatz fa34f4d2af Fix hang at nmcli call on CentOS 7.5 when ssh.pty is enabled
`vagrant up` may hang at the "Configuring and enabling network
interfaces..." step when private networks and PTY allocation for SSH
are used.

The newer version of `nmcli` that is part of CentOS now will open a
pager (i.e. `less`) for certain commands if it finds a tty. This
causes the invocations of `nmcli` in `guest_inspection.rb` to hang.

`nmcli` disables the use of a pager in 'terse' (`-t`) output mode,
while still returning enough information for the uses in
`guest_inspection.rb`.
2018-06-13 11:10:18 +02:00

64 lines
1.5 KiB
Ruby

module Vagrant
module Util
# Helper methods for inspecting guests to determine if specific services
# or applications are installed and in use
module GuestInspection
# Linux specific inspection helpers
module Linux
## systemd helpers
# systemd is in use
#
# @return [Boolean]
def systemd?(comm)
comm.test("ps -o comm= 1 | grep systemd")
end
# systemd-networkd.service is in use
#
# @return [Boolean]
def systemd_networkd?(comm)
comm.test("sudo systemctl status systemd-networkd.service")
end
# systemd hostname set is via hostnamectl
#
# @return [Boolean]
def hostnamectl?(comm)
comm.test("hostnamectl")
end
## netplan helpers
# netplan is installed
#
# @return [Boolean]
def netplan?(comm)
comm.test("netplan -h")
end
## nmcli helpers
# nmcli is installed
#
# @return [Boolean]
def nmcli?(comm)
comm.test("nmcli -t")
end
# NetworkManager currently controls device
#
# @param comm [Communicator]
# @param device_name [String]
# @return [Boolean]
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
end
end
end
end