Validate hostnamectl command is in working state

When checking if the hostnamectl command should be used for configuring
the guest hostname, ensure the command returns a valid result. The
hostnamectl command relies on dbus and if dbus is not available the
command will simply fail.
This commit is contained in:
Chris Roberts 2018-12-17 12:46:30 -08:00
parent 6bff374e79
commit 95493d6c59
1 changed files with 5 additions and 1 deletions

View File

@ -36,8 +36,12 @@ module Vagrant
# #
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @return [Boolean] # @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
def hostnamectl?(comm) def hostnamectl?(comm)
comm.test("command -v hostnamectl") comm.test("command -v hostnamectl && hostnamectl")
end end
## netplan helpers ## netplan helpers