Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b437fefd27 | ||
|
|
d9c3f4efb2 | ||
|
|
31ad65a4fe | ||
|
|
ded11117ff |
6 changed files with 791 additions and 2 deletions
42
Fixes-the-change-in-packaging-for-nfs-in-f28.patch
Normal file
42
Fixes-the-change-in-packaging-for-nfs-in-f28.patch
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
From f0b9d025e481eaf03db9a92ed51f3fe07541fa76 Mon Sep 17 00:00:00 2001
|
||||
From: langdon <langdon@fedoraproject.org>
|
||||
Date: Thu, 14 Jun 2018 15:48:13 -0400
|
||||
Subject: [PATCH] Fixes the change in packaging for nfs in f28 (#9878).
|
||||
However, removed part of the unit test which will be very difficult to fix (I
|
||||
expect). The unit test is still doing a good test that nfs and rpcbind work
|
||||
though. If you go far enough back, you need to bury the error out too.
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/nfs_client.rb | 6 +++++-
|
||||
test/unit/plugins/guests/redhat/cap/nfs_client_test.rb | 1 -
|
||||
2 files changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/nfs_client.rb b/plugins/guests/redhat/cap/nfs_client.rb
|
||||
index b1eb4c6e4b..f28a043464 100644
|
||||
--- a/plugins/guests/redhat/cap/nfs_client.rb
|
||||
+++ b/plugins/guests/redhat/cap/nfs_client.rb
|
||||
@@ -5,7 +5,11 @@ class NFSClient
|
||||
def self.nfs_client_install(machine)
|
||||
machine.communicate.sudo <<-EOH.gsub(/^ {12}/, '')
|
||||
if command -v dnf; then
|
||||
- dnf -y install nfs-utils nfs-utils-lib portmap
|
||||
+ if `dnf info -q libnfs-utils > /dev/null 2>&1` ; then
|
||||
+ dnf -y install nfs-utils libnfs-utils portmap
|
||||
+ else
|
||||
+ dnf -y install nfs-utils nfs-utils-lib portmap
|
||||
+ fi
|
||||
else
|
||||
yum -y install nfs-utils nfs-utils-lib portmap
|
||||
fi
|
||||
diff --git a/test/unit/plugins/guests/redhat/cap/nfs_client_test.rb b/test/unit/plugins/guests/redhat/cap/nfs_client_test.rb
|
||||
index a86136e19a..38a9efa69e 100644
|
||||
--- a/test/unit/plugins/guests/redhat/cap/nfs_client_test.rb
|
||||
+++ b/test/unit/plugins/guests/redhat/cap/nfs_client_test.rb
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
it "installs rsync" do
|
||||
cap.nfs_client_install(machine)
|
||||
- expect(comm.received_commands[0]).to match(/install nfs-utils nfs-utils-lib portmap/)
|
||||
expect(comm.received_commands[0]).to match(/\/bin\/systemctl restart rpcbind nfs/)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
From 30e7e81eab1d7fbb65ceb79afe3133e8df59b1e4 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Mon, 2 Apr 2018 11:53:25 -0700
|
||||
Subject: [PATCH] Make resolv-replace loading optional not automatic
|
||||
|
||||
---
|
||||
test/unit/vagrant/shared_helpers_test.rb | 19 +++++++++++++++++++
|
||||
1 files changed, 19 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/test/unit/vagrant/shared_helpers_test.rb b/test/unit/vagrant/shared_helpers_test.rb
|
||||
index da0f4c134f..64adf7bc68 100644
|
||||
--- a/test/unit/vagrant/shared_helpers_test.rb
|
||||
+++ b/test/unit/vagrant/shared_helpers_test.rb
|
||||
@@ -143,4 +143,23 @@
|
||||
expect(subject.prerelease?).to be(false)
|
||||
end
|
||||
end
|
||||
+
|
||||
+ describe "#enable_resolv_replace" do
|
||||
+ it "should not attempt to require resolv-replace by default" do
|
||||
+ expect(subject).not_to receive(:require).with("resolv-replace")
|
||||
+ subject.enable_resolv_replace
|
||||
+ end
|
||||
+
|
||||
+ it "should require resolv-replace when VAGRANT_ENABLE_RESOLV_REPLACE is set" do
|
||||
+ expect(subject).to receive(:require).with("resolv-replace")
|
||||
+ with_temp_env("VAGRANT_ENABLE_RESOLV_REPLACE" => "1"){ subject.enable_resolv_replace }
|
||||
+ end
|
||||
+
|
||||
+ it "should not require resolv-replace when VAGRANT_DISABLE_RESOLV_REPLACE is set" do
|
||||
+ expect(subject).not_to receive(:require).with("resolv-replace")
|
||||
+ with_temp_env("VAGRANT_ENABLE_RESOLV_REPLACE" => "1", "VAGRANT_DISABLE_RESOLV_REPLACE" => "1") do
|
||||
+ subject.enable_resolv_replace
|
||||
+ end
|
||||
+ end
|
||||
+ end
|
||||
end
|
||||
58
vagrant-2.0.4-Make-resolv-replace-loading-optional.patch
Normal file
58
vagrant-2.0.4-Make-resolv-replace-loading-optional.patch
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
From 30e7e81eab1d7fbb65ceb79afe3133e8df59b1e4 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Mon, 2 Apr 2018 11:53:25 -0700
|
||||
Subject: [PATCH] Make resolv-replace loading optional not automatic
|
||||
|
||||
---
|
||||
lib/vagrant/shared_helpers.rb | 16 +++++++++-------
|
||||
.../source/docs/other/environmental-variables.html.md | 9 ++++++---
|
||||
2 files changed, 15 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb
|
||||
index 839ef55e6b..ae9cd15df4 100644
|
||||
--- a/lib/vagrant/shared_helpers.rb
|
||||
+++ b/lib/vagrant/shared_helpers.rb
|
||||
@@ -134,15 +134,17 @@ def self.strict_dependency_enforcement
|
||||
#
|
||||
# @return [boolean] enabled or not
|
||||
def self.enable_resolv_replace
|
||||
- if !ENV["VAGRANT_DISABLE_RESOLV_REPLACE"]
|
||||
- begin
|
||||
- require "resolv-replace"
|
||||
- true
|
||||
- rescue
|
||||
+ if ENV["VAGRANT_ENABLE_RESOLV_REPLACE"]
|
||||
+ if !ENV["VAGRANT_DISABLE_RESOLV_REPLACE"]
|
||||
+ begin
|
||||
+ require "resolv-replace"
|
||||
+ true
|
||||
+ rescue
|
||||
+ false
|
||||
+ end
|
||||
+ else
|
||||
false
|
||||
end
|
||||
- else
|
||||
- false
|
||||
end
|
||||
end
|
||||
end
|
||||
diff --git a/website/source/docs/other/environmental-variables.html.md b/website/source/docs/other/environmental-variables.html.md
|
||||
index 8448640780..d474faf9b0 100644
|
||||
--- a/website/source/docs/other/environmental-variables.html.md
|
||||
+++ b/website/source/docs/other/environmental-variables.html.md
|
||||
@@ -219,8 +219,11 @@ shared folders. Defaults to true if the option is not set. This can be overridde
|
||||
on a per-folder basis within your Vagrantfile config by settings the
|
||||
`SharedFoldersEnableSymlinksCreate` option to true.
|
||||
|
||||
+## `VAGRANT_ENABLE_RESOLV_REPLACE`
|
||||
+
|
||||
+Use the Ruby Resolv library in place of the libc resolver.
|
||||
+
|
||||
## `VAGRANT_DISABLE_RESOLV_REPLACE`
|
||||
|
||||
-Vagrant will automatically load `resolv-replace` to use Ruby's Resolv library
|
||||
-in place of the libc resolver. This behavior can be disabled by setting this
|
||||
-environment variable.
|
||||
+Vagrant can optionally use the Ruby Resolv library in place of the libc resolver.
|
||||
+This can be disabled setting this environment variable.
|
||||
22
vagrant-2.1.2-fix-network-priority-debian-cap.patch
Normal file
22
vagrant-2.1.2-fix-network-priority-debian-cap.patch
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
From 995c43dd0cb0e365e46304d98587e1759923576e Mon Sep 17 00:00:00 2001
|
||||
From: Jaroslaw Gorny <jaroslaw.gorny@gmail.com>
|
||||
Date: Fri, 25 May 2018 00:06:20 +0200
|
||||
Subject: [PATCH] Fix issue 9592 when systemd-networkd is used by Debian guest
|
||||
|
||||
---
|
||||
plugins/guests/debian/cap/configure_networks.rb | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/guests/debian/cap/configure_networks.rb b/plugins/guests/debian/cap/configure_networks.rb
|
||||
index 6ba4c2ca94..fcc907a25a 100644
|
||||
--- a/plugins/guests/debian/cap/configure_networks.rb
|
||||
+++ b/plugins/guests/debian/cap/configure_networks.rb
|
||||
@@ -97,7 +97,7 @@ def self.configure_networkd(machine, interfaces, comm, networks)
|
||||
end
|
||||
|
||||
remote_path = upload_tmp_file(comm, net_conf.join("\n"))
|
||||
- dest_path = "#{NETWORKD_DIRECTORY}/99-vagrant.network"
|
||||
+ dest_path = "#{NETWORKD_DIRECTORY}/50-vagrant.network"
|
||||
comm.sudo(["mkdir -p #{NETWORKD_DIRECTORY}",
|
||||
"mv -f '#{remote_path}' '#{dest_path}'",
|
||||
"chown root:root '#{dest_path}'",
|
||||
590
vagrant-2.1.6-update-restart-logic-in-redhat.patch
Normal file
590
vagrant-2.1.6-update-restart-logic-in-redhat.patch
Normal file
|
|
@ -0,0 +1,590 @@
|
|||
From 80006251f422a8d534ff9bafa0e0c45d9c98143c Mon Sep 17 00:00:00 2001
|
||||
From: Joe Doss <jdoss@kennasecurity.com>
|
||||
Date: Mon, 17 Sep 2018 13:30:55 -0500
|
||||
Subject: [PATCH 01/10] Add in logic to restart NetworkManager if it is
|
||||
enabled.
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 8 +++++++-
|
||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index 55fcdc4b48..8f32650035 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -29,7 +29,13 @@ def self.change_host_name(machine, name)
|
||||
}
|
||||
|
||||
# Restart network
|
||||
- service network restart
|
||||
+ if (test -f /etc/init.d/network && /etc/init.d/network status &> /dev/null ); then
|
||||
+ service network restart
|
||||
+ elif (test -f /usr/lib/systemd/system/NetworkManager.service && systemctl is-enabled NetworkManager.service &> /dev/null ); then
|
||||
+ systemctl restart NetworkManager.service
|
||||
+ else
|
||||
+ printf "Could not restart the network to set the new hostname!\n"
|
||||
+ fi
|
||||
EOH
|
||||
end
|
||||
end
|
||||
|
||||
From 94954739b53ee4c6741a35c366c2fe5c9853e0ed Mon Sep 17 00:00:00 2001
|
||||
From: Joe Doss <jdoss@kennasecurity.com>
|
||||
Date: Mon, 17 Sep 2018 14:30:57 -0500
|
||||
Subject: [PATCH 02/10] Simplified if statements.
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index 8f32650035..e9c0b1d80e 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -29,9 +29,9 @@ def self.change_host_name(machine, name)
|
||||
}
|
||||
|
||||
# Restart network
|
||||
- if (test -f /etc/init.d/network && /etc/init.d/network status &> /dev/null ); then
|
||||
+ if test -f /etc/init.d/network; then
|
||||
service network restart
|
||||
- elif (test -f /usr/lib/systemd/system/NetworkManager.service && systemctl is-enabled NetworkManager.service &> /dev/null ); then
|
||||
+ elif systemctl -q is-enabled NetworkManager.service; then
|
||||
systemctl restart NetworkManager.service
|
||||
else
|
||||
printf "Could not restart the network to set the new hostname!\n"
|
||||
|
||||
From c14a4a09f723230682c5ef5f9dc53662e2968b92 Mon Sep 17 00:00:00 2001
|
||||
From: Joe Doss <jdoss@kennasecurity.com>
|
||||
Date: Mon, 17 Sep 2018 14:56:06 -0500
|
||||
Subject: [PATCH 03/10] Switch if statements, check for systemctl, and switch
|
||||
to is-active.
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index e9c0b1d80e..70bd496943 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -29,10 +29,10 @@ def self.change_host_name(machine, name)
|
||||
}
|
||||
|
||||
# Restart network
|
||||
- if test -f /etc/init.d/network; then
|
||||
- service network restart
|
||||
- elif systemctl -q is-enabled NetworkManager.service; then
|
||||
+ if (test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service); then
|
||||
systemctl restart NetworkManager.service
|
||||
+ elif test -f /etc/init.d/network; then
|
||||
+ service network restart
|
||||
else
|
||||
printf "Could not restart the network to set the new hostname!\n"
|
||||
fi
|
||||
|
||||
From 19aa9578c797c99a8632955a703490d5e6b50a26 Mon Sep 17 00:00:00 2001
|
||||
From: Joe Doss <jdoss@kennasecurity.com>
|
||||
Date: Tue, 18 Sep 2018 13:15:26 -0500
|
||||
Subject: [PATCH 04/10] Exit 1 if we cannot set the hostname.
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index 70bd496943..ae02460156 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -35,6 +35,7 @@ def self.change_host_name(machine, name)
|
||||
service network restart
|
||||
else
|
||||
printf "Could not restart the network to set the new hostname!\n"
|
||||
+ exit 1
|
||||
fi
|
||||
EOH
|
||||
end
|
||||
|
||||
From 86ab4533b180009ed476026374110fc0bd79f522 Mon Sep 17 00:00:00 2001
|
||||
From: Joe Doss <jdoss@kennasecurity.com>
|
||||
Date: Tue, 18 Sep 2018 13:16:12 -0500
|
||||
Subject: [PATCH 05/10] Fix the test to check for systemctl restart
|
||||
NetworkManager.service too.
|
||||
|
||||
---
|
||||
test/unit/plugins/guests/redhat/cap/change_host_name_test.rb | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
index 7662935458..10f43a3593 100644
|
||||
--- a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
+++ b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
@@ -31,7 +31,7 @@
|
||||
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network-scripts\/ifcfg/)
|
||||
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --static '#{name}'/)
|
||||
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --transient '#{name}'/)
|
||||
- expect(comm.received_commands[1]).to match(/service network restart/)
|
||||
+ expect(comm.received_commands[1]).to match(/service network restart|systemctl restart NetworkManager.service/)
|
||||
end
|
||||
|
||||
it "does not change the hostname if already set" do
|
||||
|
||||
From a12b09b098ea87eec815e166d0e1395f6f47f937 Mon Sep 17 00:00:00 2001
|
||||
From: shotop <samuel.j.hotop@gmail.com>
|
||||
Date: Thu, 20 Sep 2018 14:21:40 -0500
|
||||
Subject: [PATCH 06/10] add specs around network restart logic
|
||||
|
||||
---
|
||||
.../redhat/cap/change_host_name_test.rb | 27 +++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
index 10f43a3593..b85802e947 100644
|
||||
--- a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
+++ b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
@@ -39,5 +39,32 @@
|
||||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands.size).to eq(1)
|
||||
end
|
||||
+
|
||||
+ context "restarts the network" do
|
||||
+ it "uses systemctl and NetworkManager.service" do
|
||||
+ comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
+ comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 0)
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[1]).to match(/systemctl restart NetworkManager.service/)
|
||||
+ end
|
||||
+
|
||||
+ it "uses the service command" do
|
||||
+ comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
+ comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
+ comm.stub_command("test -f /etc/init.d/network", exit_code: 0)
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[1]).to match(/service network restart/)
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ context "cannot restart the network" do
|
||||
+ it "prints cannot restart message" do
|
||||
+ comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
+ comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
+ comm.stub_command("test -f /etc/init.d/network", exit_code: 1)
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[1]).to match(/printf "Could not restart the network to set the new hostname!/)
|
||||
+ end
|
||||
+ end
|
||||
end
|
||||
end
|
||||
|
||||
From fb5fc0e657a10ee1eaf046980827cc1802c4d0f9 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Thu, 20 Sep 2018 16:42:39 -0700
|
||||
Subject: [PATCH 07/10] Update guest inspection utility module
|
||||
|
||||
Use sudo option for communicator test command instead of inline sudo
|
||||
to properly use configured sudo value. Use command for checking
|
||||
availability of hostnamectl. Use is-active for determining if a
|
||||
service is being actively managed by systemd.
|
||||
---
|
||||
lib/vagrant/util/guest_inspection.rb | 19 ++++++++++++++++---
|
||||
1 file changed, 16 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/vagrant/util/guest_inspection.rb b/lib/vagrant/util/guest_inspection.rb
|
||||
index 86ab1dc69e..5a1902d8da 100644
|
||||
--- a/lib/vagrant/util/guest_inspection.rb
|
||||
+++ b/lib/vagrant/util/guest_inspection.rb
|
||||
@@ -17,22 +17,34 @@ module Linux
|
||||
|
||||
# systemd-networkd.service is in use
|
||||
#
|
||||
+ # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def systemd_networkd?(comm)
|
||||
- comm.test("sudo systemctl status systemd-networkd.service")
|
||||
+ comm.test("systemctl -q is-active systemd-networkd.service", sudo: true)
|
||||
+ end
|
||||
+
|
||||
+ # 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]
|
||||
+ def systemd_controlled?(comm, service_name)
|
||||
+ comm.test("systemctl -q is-active #{service_name}", sudo: true)
|
||||
end
|
||||
|
||||
# systemd hostname set is via hostnamectl
|
||||
#
|
||||
+ # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def hostnamectl?(comm)
|
||||
- comm.test("hostnamectl")
|
||||
+ comm.test("command -v hostnamectl")
|
||||
end
|
||||
|
||||
## netplan helpers
|
||||
|
||||
# netplan is installed
|
||||
#
|
||||
+ # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def netplan?(comm)
|
||||
comm.test("netplan -h")
|
||||
@@ -42,6 +54,7 @@ def netplan?(comm)
|
||||
|
||||
# nmcli is installed
|
||||
#
|
||||
+ # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def nmcli?(comm)
|
||||
comm.test("nmcli")
|
||||
@@ -49,7 +62,7 @@ def nmcli?(comm)
|
||||
|
||||
# NetworkManager currently controls device
|
||||
#
|
||||
- # @param comm [Communicator]
|
||||
+ # @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @param device_name [String]
|
||||
# @return [Boolean]
|
||||
def nm_controlled?(comm, device_name)
|
||||
|
||||
From ff021fcab404c95e52566bfca4207da9c0101e01 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Thu, 20 Sep 2018 16:44:08 -0700
|
||||
Subject: [PATCH 08/10] Update redhat change host name capability to support
|
||||
systemd
|
||||
|
||||
Update capability to use guest inspection module for determining
|
||||
correct actions to execute. When systemd is in use restart the
|
||||
correct active service, either NetworkManager or networkd. Default
|
||||
to using the original service restart when systemd service is not
|
||||
found.
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 41 ++++++++++---------
|
||||
1 file changed, 21 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index ae02460156..5da660df05 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -2,6 +2,9 @@ module VagrantPlugins
|
||||
module GuestRedHat
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
+
|
||||
+ extend Vagrant::Util::GuestInspection
|
||||
+
|
||||
def self.change_host_name(machine, name)
|
||||
comm = machine.communicate
|
||||
|
||||
@@ -10,34 +13,32 @@ def self.change_host_name(machine, name)
|
||||
comm.sudo <<-EOH.gsub(/^ {14}/, '')
|
||||
# Update sysconfig
|
||||
sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network
|
||||
-
|
||||
# Update DNS
|
||||
sed -i 's/\\(DHCP_HOSTNAME=\\).*/\\1\"#{basename}\"/' /etc/sysconfig/network-scripts/ifcfg-*
|
||||
-
|
||||
# Set the hostname - use hostnamectl if available
|
||||
echo '#{name}' > /etc/hostname
|
||||
- if command -v hostnamectl; then
|
||||
- hostnamectl set-hostname --static '#{name}'
|
||||
- hostnamectl set-hostname --transient '#{name}'
|
||||
- else
|
||||
- hostname -F /etc/hostname
|
||||
- fi
|
||||
-
|
||||
- # Prepend ourselves to /etc/hosts
|
||||
grep -w '#{name}' /etc/hosts || {
|
||||
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
|
||||
}
|
||||
-
|
||||
- # Restart network
|
||||
- if (test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service); then
|
||||
- systemctl restart NetworkManager.service
|
||||
- elif test -f /etc/init.d/network; then
|
||||
- service network restart
|
||||
- else
|
||||
- printf "Could not restart the network to set the new hostname!\n"
|
||||
- exit 1
|
||||
- fi
|
||||
EOH
|
||||
+
|
||||
+ if hostnamectl?(comm)
|
||||
+ comm.sudo("hostnamectl set-hostname --static '#{name}' ; " \
|
||||
+ "hostnamectl set-hostname --transient '#{name}'")
|
||||
+ else
|
||||
+ comm.sudo("hostname -F /etc/hostname")
|
||||
+ end
|
||||
+
|
||||
+ restart_command = "service network restart"
|
||||
+
|
||||
+ if systemd?
|
||||
+ if systemd_networkd?(comm)
|
||||
+ restart_command = "systemctl restart systemd-networkd.service"
|
||||
+ elsif systemd_controlled?(comm, "NetworkManager.service")
|
||||
+ restart_command = "systemctl restart NetworkManager.service"
|
||||
+ end
|
||||
+ end
|
||||
+ comm.sudo(restart_command)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
From bc217d5e577457df5ac4ecdfffa17fd0a8c85b18 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Thu, 20 Sep 2018 16:46:45 -0700
|
||||
Subject: [PATCH 09/10] Update redhat change host name capability tests for
|
||||
systemd/NetworkManger updates
|
||||
|
||||
---
|
||||
.../redhat/cap/change_host_name_test.rb | 95 +++++++++++++------
|
||||
1 file changed, 68 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
index b85802e947..8d0c9ebd4b 100644
|
||||
--- a/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
+++ b/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb
|
||||
@@ -20,50 +20,91 @@
|
||||
|
||||
describe ".change_host_name" do
|
||||
let(:cap) { caps.get(:change_host_name) }
|
||||
-
|
||||
let(:name) { "banana-rama.example.com" }
|
||||
+ let(:hostname_changed) { true }
|
||||
+ let(:systemd) { true }
|
||||
+ let(:hostnamectl) { true }
|
||||
+ let(:networkd) { true }
|
||||
+ let(:network_manager) { false }
|
||||
|
||||
- it "sets the hostname" do
|
||||
- comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
+ before do
|
||||
+ comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: hostname_changed ? 1 : 0)
|
||||
+ allow(cap).to receive(:systemd?).and_return(systemd)
|
||||
+ allow(cap).to receive(:hostnamectl?).and_return(hostnamectl)
|
||||
+ allow(cap).to receive(:systemd_networkd?).and_return(networkd)
|
||||
+ allow(cap).to receive(:systemd_controlled?).with(anything, /NetworkManager/).and_return(network_manager)
|
||||
+ end
|
||||
|
||||
+ it "sets the hostname" do
|
||||
cap.change_host_name(machine, name)
|
||||
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network/)
|
||||
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network-scripts\/ifcfg/)
|
||||
- expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --static '#{name}'/)
|
||||
- expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --transient '#{name}'/)
|
||||
- expect(comm.received_commands[1]).to match(/service network restart|systemctl restart NetworkManager.service/)
|
||||
end
|
||||
|
||||
- it "does not change the hostname if already set" do
|
||||
- comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
|
||||
- cap.change_host_name(machine, name)
|
||||
- expect(comm.received_commands.size).to eq(1)
|
||||
- end
|
||||
+ context "when hostnamectl is in use" do
|
||||
+ let(:hostnamectl) { true }
|
||||
|
||||
- context "restarts the network" do
|
||||
- it "uses systemctl and NetworkManager.service" do
|
||||
- comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
- comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 0)
|
||||
+ it "sets hostname with hostnamectl" do
|
||||
cap.change_host_name(machine, name)
|
||||
- expect(comm.received_commands[1]).to match(/systemctl restart NetworkManager.service/)
|
||||
+ expect(comm.received_commands[2]).to match(/hostnamectl/)
|
||||
end
|
||||
+ end
|
||||
+
|
||||
+ context "when hostnamectl is not in use" do
|
||||
+ let(:hostnamectl) { false }
|
||||
|
||||
- it "uses the service command" do
|
||||
- comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
- comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
- comm.stub_command("test -f /etc/init.d/network", exit_code: 0)
|
||||
+ it "sets hostname with hostname command" do
|
||||
cap.change_host_name(machine, name)
|
||||
- expect(comm.received_commands[1]).to match(/service network restart/)
|
||||
+ expect(comm.received_commands[2]).to match(/hostname -F/)
|
||||
end
|
||||
end
|
||||
|
||||
- context "cannot restart the network" do
|
||||
- it "prints cannot restart message" do
|
||||
- comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
|
||||
- comm.stub_command("test -f /usr/bin/systemctl && systemctl -q is-active NetworkManager.service", exit_code: 1)
|
||||
- comm.stub_command("test -f /etc/init.d/network", exit_code: 1)
|
||||
+ context "when host name is already set" do
|
||||
+ let(:hostname_changed) { false }
|
||||
+
|
||||
+ it "does not change the hostname" do
|
||||
cap.change_host_name(machine, name)
|
||||
- expect(comm.received_commands[1]).to match(/printf "Could not restart the network to set the new hostname!/)
|
||||
+ expect(comm.received_commands.size).to eq(1)
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ context "restarts the network" do
|
||||
+ context "when networkd is in use" do
|
||||
+ let(:networkd) { true }
|
||||
+
|
||||
+ it "restarts networkd with systemctl" do
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[3]).to match(/systemctl restart systemd-networkd/)
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ context "when NetworkManager is in use" do
|
||||
+ let(:networkd) { false }
|
||||
+ let(:network_manager) { true }
|
||||
+
|
||||
+ it "restarts NetworkManager with systemctl" do
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[3]).to match(/systemctl restart NetworkManager/)
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ context "when networkd and NetworkManager are not in use" do
|
||||
+ let(:networkd) { false }
|
||||
+ let(:network_manager) { false }
|
||||
+
|
||||
+ it "restarts the network using service" do
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[3]).to match(/service network restart/)
|
||||
+ end
|
||||
+ end
|
||||
+
|
||||
+ context "when systemd is not in use" do
|
||||
+ let(:systemd) { false }
|
||||
+
|
||||
+ it "restarts the network using service" do
|
||||
+ cap.change_host_name(machine, name)
|
||||
+ expect(comm.received_commands[3]).to match(/service network restart/)
|
||||
+ end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
From 8fd05fe3c1b773777f08ca50dd651cbaf33838d3 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Fri, 21 Sep 2018 09:19:40 -0700
|
||||
Subject: [PATCH 10/10] Use `command -v` for checks in all inspection helpers.
|
||||
Fix stubs in tests.
|
||||
|
||||
---
|
||||
lib/vagrant/util/guest_inspection.rb | 4 ++--
|
||||
.../guests/debian/cap/configure_networks_test.rb | 14 +++++++-------
|
||||
2 files changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/lib/vagrant/util/guest_inspection.rb b/lib/vagrant/util/guest_inspection.rb
|
||||
index 5a1902d8da..cd0a96d3ef 100644
|
||||
--- a/lib/vagrant/util/guest_inspection.rb
|
||||
+++ b/lib/vagrant/util/guest_inspection.rb
|
||||
@@ -47,7 +47,7 @@ def hostnamectl?(comm)
|
||||
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def netplan?(comm)
|
||||
- comm.test("netplan -h")
|
||||
+ comm.test("command -v netplan")
|
||||
end
|
||||
|
||||
## nmcli helpers
|
||||
--- a/lib/vagrant/util/guest_inspection.rb
|
||||
+++ b/lib/vagrant/util/guest_inspection.rb
|
||||
@@ -57,7 +57,7 @@ def netplan?(comm)
|
||||
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
|
||||
# @return [Boolean]
|
||||
def nmcli?(comm)
|
||||
- comm.test("nmcli")
|
||||
+ comm.test("command -v nmcli")
|
||||
end
|
||||
|
||||
# NetworkManager currently controls device
|
||||
diff --git a/test/unit/plugins/guests/debian/cap/configure_networks_test.rb b/test/unit/plugins/guests/debian/cap/configure_networks_test.rb
|
||||
index b4691d0fd4..d3a523c95b 100644
|
||||
--- a/test/unit/plugins/guests/debian/cap/configure_networks_test.rb
|
||||
+++ b/test/unit/plugins/guests/debian/cap/configure_networks_test.rb
|
||||
@@ -66,8 +66,8 @@
|
||||
|
||||
before do
|
||||
allow(comm).to receive(:test).with("systemctl | grep '^-.mount'").and_return(false)
|
||||
- allow(comm).to receive(:test).with("sudo systemctl status systemd-networkd.service").and_return(false)
|
||||
- allow(comm).to receive(:test).with("netplan -h").and_return(false)
|
||||
+ allow(comm).to receive(:test).with("systemctl -q is-active systemd-networkd.service", anything).and_return(false)
|
||||
+ allow(comm).to receive(:test).with("command -v netplan").and_return(false)
|
||||
end
|
||||
|
||||
it "creates and starts the networks using net-tools" do
|
||||
@@ -83,7 +83,7 @@
|
||||
context "with systemd" do
|
||||
before do
|
||||
expect(comm).to receive(:test).with("systemctl | grep '^-.mount'").and_return(true)
|
||||
- allow(comm).to receive(:test).with("netplan -h").and_return(false)
|
||||
+ allow(comm).to receive(:test).with("command -v netplan").and_return(false)
|
||||
end
|
||||
|
||||
it "creates and starts the networks using net-tools" do
|
||||
@@ -100,7 +100,7 @@
|
||||
|
||||
context "with systemd-networkd" do
|
||||
before do
|
||||
- expect(comm).to receive(:test).with("sudo systemctl status systemd-networkd.service").and_return(true)
|
||||
+ expect(comm).to receive(:test).with("systemctl -q is-active systemd-networkd.service", anything).and_return(true)
|
||||
end
|
||||
|
||||
it "creates and starts the networks using systemd-networkd" do
|
||||
@@ -115,7 +115,7 @@
|
||||
|
||||
context "with netplan" do
|
||||
before do
|
||||
- expect(comm).to receive(:test).with("netplan -h").and_return(true)
|
||||
+ expect(comm).to receive(:test).with("command -v netplan").and_return(true)
|
||||
end
|
||||
|
||||
it "creates and starts the networks for systemd with netplan" do
|
||||
|
||||
From 1797798760eb72d6b02724f75bc54dd83815e986 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Fri, 28 Sep 2018 07:59:39 -0700
|
||||
Subject: [PATCH] Fix module name
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index 5da660df05..37c8912a80 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -3,7 +3,7 @@ module GuestRedHat
|
||||
module Cap
|
||||
class ChangeHostName
|
||||
|
||||
- extend Vagrant::Util::GuestInspection
|
||||
+ extend Vagrant::Util::GuestInspection::Linux
|
||||
|
||||
def self.change_host_name(machine, name)
|
||||
comm = machine.communicate
|
||||
|
||||
From 11b0d58fa081cd9a27c272244a0d119acc81f32e Mon Sep 17 00:00:00 2001
|
||||
From: Chris Roberts <croberts@hashicorp.com>
|
||||
Date: Mon, 1 Oct 2018 08:43:49 -0700
|
||||
Subject: [PATCH] Include communicator on call
|
||||
|
||||
---
|
||||
plugins/guests/redhat/cap/change_host_name.rb | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
index 37c8912a80..5ceb63665a 100644
|
||||
--- a/plugins/guests/redhat/cap/change_host_name.rb
|
||||
+++ b/plugins/guests/redhat/cap/change_host_name.rb
|
||||
@@ -31,7 +31,7 @@ def self.change_host_name(machine, name)
|
||||
|
||||
restart_command = "service network restart"
|
||||
|
||||
- if systemd?
|
||||
+ if systemd?(comm)
|
||||
if systemd_networkd?(comm)
|
||||
restart_command = "systemctl restart systemd-networkd.service"
|
||||
elsif systemd_controlled?(comm, "NetworkManager.service")
|
||||
44
vagrant.spec
44
vagrant.spec
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Name: vagrant
|
||||
Version: 2.0.2
|
||||
Release: 1%{?dist}
|
||||
Release: 5%{?dist}
|
||||
Summary: Build and distribute virtualized development environments
|
||||
Group: Development/Languages
|
||||
License: MIT
|
||||
|
|
@ -30,6 +30,28 @@ Patch0: vagrant-2.0.2-fix-dependencies.patch
|
|||
# https://github.com/hashicorp/vagrant/pull/9422
|
||||
Patch1: vagrant-2.0.2-use-numerical-instead-localhost.patch
|
||||
|
||||
# Make resolv-replace loading optional not automatic
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1605016
|
||||
# https://github.com/hashicorp/vagrant/pull/9644/commits/30e7e81eab1d7fbb65ceb79afe3133e8df59b1e4
|
||||
Patch2: vagrant-2.0.4-Make-resolv-replace-loading-optional.patch
|
||||
Patch3: vagrant-2.0.4-Make-resolv-replace-loading-optional-tests.patch
|
||||
|
||||
# handle rename of nfs-utils-lib/libnfs-utils in F28
|
||||
# https://github.com/hashicorp/vagrant/pull/9935/commits/f0b9d025e481eaf03db9a92ed51f3fe07541fa76
|
||||
Patch4: Fixes-the-change-in-packaging-for-nfs-in-f28.patch
|
||||
|
||||
# Update restart logic in redhat change_host_name cap
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1624068
|
||||
# https://github.com/hashicorp/vagrant/pull/10223
|
||||
# https://github.com/hashicorp/vagrant/commit/11b0d58fa081cd9a27c272244a0d119acc81f32e
|
||||
# https://github.com/hashicorp/vagrant/commit/1797798760eb72d6b02724f75bc54dd83815e986
|
||||
Patch5: vagrant-2.1.6-update-restart-logic-in-redhat.patch
|
||||
|
||||
# Fix network priority when systemd-networkd is used by Debian guest
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1582459
|
||||
# https://github.com/hashicorp/vagrant/pull/9867
|
||||
Patch6: vagrant-2.1.2-fix-network-priority-debian-cap.patch
|
||||
|
||||
Requires: ruby(release)
|
||||
Requires: ruby(rubygems) >= 1.3.6
|
||||
# Explicitly specify MRI, since Vagrant does not work with JRuby ATM.
|
||||
|
|
@ -101,6 +123,10 @@ Documentation for %{name}.
|
|||
%setup -q -b2
|
||||
|
||||
%patch0 -p1
|
||||
%patch2 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
|
||||
%build
|
||||
gem build %{name}.gemspec
|
||||
|
|
@ -163,6 +189,7 @@ EOF
|
|||
|
||||
%check
|
||||
cat %{PATCH1} | patch -p1
|
||||
cat %{PATCH3} | patch -p1
|
||||
|
||||
# Adjust the vagrant-spec directory name.
|
||||
rm -rf ../vagrant-spec
|
||||
|
|
@ -254,7 +281,7 @@ begin
|
|||
rescue => e
|
||||
puts "Vagrant plugin un-register error: #{e}"
|
||||
end
|
||||
|
||||
|
||||
%files
|
||||
# Explicitly include Vagrant plugins directory strucure to avoid accidentally
|
||||
# packaged content.
|
||||
|
|
@ -312,6 +339,19 @@ end
|
|||
|
||||
|
||||
%changelog
|
||||
* Mon Dec 03 2018 Pavel Valena <pvalena@redhat.com> - 2.0.2-5
|
||||
- Fix network priority when systemd-networkd is used by Debian
|
||||
guest(rhbz#1582459).
|
||||
|
||||
* Wed Oct 24 2018 Pavel Valena <pvalena@redhat.com> - 2.0.2-4
|
||||
- Update restart logic for redhat change_host_name cap(rhbz#1624068)
|
||||
|
||||
* Wed Sep 12 2018 Tobias Jungel <tobias.jungel@bisdn.de> - 2.0.2-3
|
||||
- handle rename of nfs-utils-lib/libnfs-utils in F28 guests (rhbz#1620074).
|
||||
|
||||
* Fri Jul 20 2018 Pavel Valena <pvalena@redhat.com> - 2.0.2-2
|
||||
- Fix: Make resolv-replace loading optional(rhbz#1605016).
|
||||
|
||||
* Wed Jan 31 2018 Pavel Valena <pvalena@redhat.com> - 2.0.2-1
|
||||
- Update to Vagrant 2.0.2.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue