diff --git a/SOURCES/ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch b/SOURCES/ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch new file mode 100644 index 0000000..120423b --- /dev/null +++ b/SOURCES/ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch @@ -0,0 +1,81 @@ +From c539cdaf0348e2a52f0947d018b3d32fc63dc1f4 Mon Sep 17 00:00:00 2001 +From: Emanuele Giuseppe Esposito +Date: Tue, 15 Jun 2021 14:01:12 +0200 +Subject: [PATCH] Fix unit failure of cloud-final.service if NetworkManager was + not present. + +RH-Author: Emanuele Giuseppe Esposito +RH-MergeRequest: 17: Fix unit failure of cloud-final.service if NetworkManager was not present. +RH-Commit: [1/1] 647305809fc533ef2c5b8e0e27c94a4f7c368728 (eesposit/cloud-init) +RH-Bugzilla: 1897616 +RH-Acked-by: Eduardo Otubo +RH-Acked-by: Vitaly Kuznetsov +RH-Acked-by: Mohamed Gamal Morsy + +Branch: rhel-7.9 +Brew: 37493950 + +commit d3889c4645a1319c3d677006164b618ee53f4c8b +Author: Eduardo Otubo +Date: Mon Dec 7 14:23:22 2020 +0100 + + Fix unit failure of cloud-final.service if NetworkManager was not present. + + RH-Author: Eduardo Terrell Ferrari Otubo (eterrell) + RH-MergeRequest: 27: Fix unit failure of cloud-final.service if NetworkManager was not present. + RH-Commit: [1/1] 3c65a2cca140fff48df1ef32919e3cb035506a2b (eterrell/cloud-init) + RH-Bugzilla: 1898943 + + cloud-final.service would fail if NetworkManager was not installed. + + journal -u cloud-final.service would show: + + cloud-init[5328]: Cloud-init v. 19.4 finished at ... + echo[5346]: try restart NetworkManager.service + systemctl[5349]: Failed to reload-or-try-restart + NetworkManager.service: Unit not found. + systemd[1]: cloud-final.service: control process exited, + code=exited status=5 + systemd[1]: Failed to start Execute cloud user/final scripts. + systemd[1]: Unit cloud-final.service entered failed state. + systemd[1]: cloud-final.service failed. + + The change here is to only attempt to restart NetworkManager if it is + present, and its SubState is 'running'. + + The multi-line shell in a systemd unit is less than ideal, but I'm not + aware of any other way of conditionally doing this. + + Note that both of 'try-reload-or-restart' and 'reload-or-try-restart' + will fail if the service is not present. So this would also affect rhel + 8 systems that do not use NetworkManager. + + Signed-off-by: Eduardo Otubo + +Signed-off-by: Emanuele Giuseppe Esposito +--- + rhel/systemd/cloud-final.service | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/rhel/systemd/cloud-final.service b/rhel/systemd/cloud-final.service +index 621d4f8c..9dad1051 100644 +--- a/rhel/systemd/cloud-final.service ++++ b/rhel/systemd/cloud-final.service +@@ -11,9 +11,12 @@ ExecStart=/usr/bin/cloud-init modules --mode=final + RemainAfterExit=yes + TimeoutSec=0 + KillMode=process +-ExecStartPost=/bin/echo "try restart NetworkManager.service" ++# Restart NetworkManager if it is present and running. + # TODO: try-reload-or-restart is available only on systemd >= 229 +-ExecStartPost=/usr/bin/systemctl reload-or-try-restart NetworkManager.service ++ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \ ++ out=$(systemctl show --property=SubState $u) || exit; \ ++ [ "$out" = "SubState=running" ] || exit 0; \ ++ systemctl reload-or-try-restart $u' + + # Output needs to appear in instance console output + StandardOutput=journal+console +-- +2.27.0 + diff --git a/SOURCES/cloud-init-centos-user.patch b/SOURCES/cloud-init-centos-user.patch deleted file mode 100644 index 2f8118b..0000000 --- a/SOURCES/cloud-init-centos-user.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -uNrp cloud-init-19.4.orig/rhel/cloud.cfg cloud-init-19.4/rhel/cloud.cfg ---- cloud-init-19.4.orig/rhel/cloud.cfg 2020-10-13 14:40:36.353779891 +0000 -+++ cloud-init-19.4/rhel/cloud.cfg 2020-10-13 14:42:10.121982459 +0000 -@@ -54,7 +54,7 @@ cloud_final_modules: - - system_info: - default_user: -- name: cloud-user -+ name: centos - lock_passwd: true - gecos: Cloud User - groups: [adm, systemd-journal] diff --git a/SPECS/cloud-init.spec b/SPECS/cloud-init.spec index 8702f9f..e3734e8 100644 --- a/SPECS/cloud-init.spec +++ b/SPECS/cloud-init.spec @@ -13,7 +13,7 @@ Name: cloud-init Version: 19.4 -Release: 7%{?dist}.4 +Release: 7%{?dist}.5 Summary: Cloud instance init scripts Group: System Environment/Base @@ -64,8 +64,8 @@ Patch23: ci-DHCP-sandboxing-failing-on-noexec-mounted-var-tmp-52.patch Patch24: ci-network-Fix-type-and-respect-name-when-rendering-vla.patch # For bz#1900807 - Update existing user password RHEL7x Patch25: ci-DataSourceAzure-update-password-for-defuser-if-exist.patch - -Patch9999: cloud-init-centos-user.patch +# For bz#1897616 - [rhel-7]cloud-final.service fails if NetworkManager not installed. +Patch26: ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch # Deal with noarch -> arch # https://bugzilla.redhat.com/show_bug.cgi?id=1067089 @@ -236,6 +236,11 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Tue Jun 29 2021 Miroslav Rezanina - 19.4-7.el7_9.5 +- ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch [bz#1897616] +- Resolves: bz#1897616 + ([rhel-7]cloud-final.service fails if NetworkManager not installed.) + * Tue Feb 16 2021 Jon Maloy - 19.4-7.el7_9.4 - ci-DataSourceAzure-update-password-for-defuser-if-exist.patch [bz#1900807] - Resolves: bz#1900807