diff --git a/SOURCES/ci-Ensure-network-ready-before-cloud-init-service-runs-.patch b/SOURCES/ci-Ensure-network-ready-before-cloud-init-service-runs-.patch new file mode 100644 index 0000000..cc65e3e --- /dev/null +++ b/SOURCES/ci-Ensure-network-ready-before-cloud-init-service-runs-.patch @@ -0,0 +1,43 @@ +From df1c0f391537071c34652ee6df9bff87e5aea230 Mon Sep 17 00:00:00 2001 +From: Emanuele Giuseppe Esposito +Date: Wed, 14 Dec 2022 09:20:47 +0100 +Subject: [PATCH] Ensure network ready before cloud-init service runs on RHEL + (#1893) + +RH-Author: Emanuele Giuseppe Esposito +RH-MergeRequest: 87: Ensure network ready before cloud-init service runs on RHEL (#1893) +RH-Bugzilla: 2151861 +RH-Acked-by: Mohamed Gamal Morsy +RH-Acked-by: Camilla Conte +RH-Commit: [1/1] 5bb5f6f94a205854633fb1606ccc68e838c2030d + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2151861 + +commit 6e725f36647407d201af0603d7db11fc96a93d4d +Author: James Falcon +Date: Tue Dec 13 10:55:23 2022 -0600 + + Ensure network ready before cloud-init service runs on RHEL (#1893) + + LP: #1998655 + +Signed-off-by: Emanuele Giuseppe Esposito +--- + systemd/cloud-init.service.tmpl | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl +index c170aef7..fc984d5c 100644 +--- a/systemd/cloud-init.service.tmpl ++++ b/systemd/cloud-init.service.tmpl +@@ -16,6 +16,7 @@ After=networking.service + "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %} + After=network.service + After=NetworkManager.service ++After=NetworkManager-wait-online.service + {% endif %} + {% if variant in ["suse"] %} + After=wicked.service +-- +2.38.1 + diff --git a/SOURCES/ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch b/SOURCES/ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch new file mode 100644 index 0000000..69ec964 --- /dev/null +++ b/SOURCES/ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch @@ -0,0 +1,84 @@ +From ddfd2eba79b4849309c37472dfb5852811b03391 Mon Sep 17 00:00:00 2001 +From: Emanuele Giuseppe Esposito +Date: Thu, 19 Jan 2023 09:46:10 +0100 +Subject: [PATCH] cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if + it's empty (#1967) + +RH-Author: Emanuele Giuseppe Esposito +RH-MergeRequest: 88: cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if it's empty (#1967) +RH-Bugzilla: 2162258 +RH-Acked-by: Mohamed Gamal Morsy +RH-Acked-by: Jon Maloy +RH-Commit: [1/1] 04aaaf46290c4488dd46c9c2673b0bf038b7d311 + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2162258 + +commit 9c7502a801763520639c66125eb373123d1e4f44 +Author: Emanuele Giuseppe Esposito +Date: Wed Jan 18 17:55:16 2023 +0100 + + cc_set_hostname: ignore /var/lib/cloud/data/set-hostname if it's empty (#1967) + + If the file exists but is empty, do nothing. + Otherwise cloud-init will crash because it does not handle the empty file. + + RHBZ: 2140893 + + Signed-off-by: Emanuele Giuseppe Esposito + +Signed-off-by: Emanuele Giuseppe Esposito +--- + cloudinit/config/cc_set_hostname.py | 2 +- + tests/unittests/config/test_cc_set_hostname.py | 17 +++++++++++++++++ + 2 files changed, 18 insertions(+), 1 deletion(-) + +diff --git a/cloudinit/config/cc_set_hostname.py b/cloudinit/config/cc_set_hostname.py +index eb0ca328..9d78f6ad 100644 +--- a/cloudinit/config/cc_set_hostname.py ++++ b/cloudinit/config/cc_set_hostname.py +@@ -86,7 +86,7 @@ def handle(name, cfg, cloud, log, _args): + # distro._read_hostname implementation so we only validate one artifact. + prev_fn = os.path.join(cloud.get_cpath("data"), "set-hostname") + prev_hostname = {} +- if os.path.exists(prev_fn): ++ if os.path.exists(prev_fn) and os.stat(prev_fn).st_size > 0: + prev_hostname = util.load_json(util.load_file(prev_fn)) + hostname_changed = hostname != prev_hostname.get( + "hostname" +diff --git a/tests/unittests/config/test_cc_set_hostname.py b/tests/unittests/config/test_cc_set_hostname.py +index fd994c4e..a819039b 100644 +--- a/tests/unittests/config/test_cc_set_hostname.py ++++ b/tests/unittests/config/test_cc_set_hostname.py +@@ -5,6 +5,7 @@ import os + import shutil + import tempfile + from io import BytesIO ++from pathlib import Path + from unittest import mock + + from configobj import ConfigObj +@@ -204,5 +205,21 @@ class TestHostname(t_help.FilesystemMockingTestCase): + str(ctx_mgr.exception), + ) + ++ def test_ignore_empty_previous_artifact_file(self): ++ cfg = { ++ "hostname": "blah", ++ "fqdn": "blah.blah.blah.yahoo.com", ++ } ++ distro = self._fetch_distro("debian") ++ paths = helpers.Paths({"cloud_dir": self.tmp}) ++ ds = None ++ cc = cloud.Cloud(ds, paths, {}, distro, None) ++ self.patchUtils(self.tmp) ++ prev_fn = Path(cc.get_cpath("data")) / "set-hostname" ++ prev_fn.touch() ++ cc_set_hostname.handle("cc_set_hostname", cfg, cc, LOG, []) ++ contents = util.load_file("/etc/hostname") ++ self.assertEqual("blah", contents.strip()) ++ + + # vi: ts=4 expandtab +-- +2.39.1 + diff --git a/SOURCES/ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch b/SOURCES/ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch new file mode 100644 index 0000000..8949652 --- /dev/null +++ b/SOURCES/ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch @@ -0,0 +1,146 @@ +From 528136e7f6c307f035f8db0f14313a213697d2d0 Mon Sep 17 00:00:00 2001 +From: Emanuele Giuseppe Esposito +Date: Thu, 8 Sep 2022 17:42:26 +0200 +Subject: [PATCH] cloud.cfg.tmpl: make sure "centos" settings are identical to + "rhel" (#1639) + +RH-Author: Emanuele Giuseppe Esposito +RH-MergeRequest: 83: cloud.cfg.tmpl: make sure "centos" settings are identical to "rhel" (#1639) +RH-Bugzilla: 2115576 +RH-Acked-by: Camilla Conte +RH-Acked-by: Jon Maloy +RH-Commit: [1/1] f503ce4f79b7d783cd0a4e1ed0977e63a4715031 + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2115576 + +commit 7593243a1abe2ccaf4698579720999380a4da73b +Author: Emanuele Giuseppe Esposito +Date: Wed Sep 7 14:53:26 2022 +0200 + + cloud.cfg.tmpl: make sure "centos" settings are identical to "rhel" (#1639) + + We have a couple of bugs where centos does not have the default user as rhel. + This PR makes sure the configuration is exactly the same. + + Signed-off-by: Emanuele Giuseppe Esposito + + RHBZ: 2115565 + RHBZ: 2115576 + Conflicts: + config/cloud.cfg.tmpl: "openmandriva" distro added in the options + +Signed-off-by: Emanuele Giuseppe Esposito +--- + config/cloud.cfg.tmpl | 27 +++++++++++++------------ + tests/unittests/test_render_cloudcfg.py | 1 + + 2 files changed, 15 insertions(+), 13 deletions(-) + +diff --git a/config/cloud.cfg.tmpl b/config/cloud.cfg.tmpl +index 80ab4f96..08b6efbc 100644 +--- a/config/cloud.cfg.tmpl ++++ b/config/cloud.cfg.tmpl +@@ -2,6 +2,7 @@ + # The top level settings are used as module + # and system configuration. + {% set is_bsd = variant in ["dragonfly", "freebsd", "netbsd", "openbsd"] %} ++{% set is_rhel = variant in ["rhel", "centos"] %} + {% if is_bsd %} + syslog_fix_perms: root:wheel + {% elif variant in ["suse"] %} +@@ -32,9 +33,9 @@ disable_root: false + disable_root: true + {% endif %} + +-{% if variant in ["almalinux", "alpine", "amazon", "centos", "cloudlinux", "eurolinux", +- "fedora", "miraclelinux", "openEuler", "rhel", "rocky", "virtuozzo"] %} +-{% if variant == "rhel" %} ++{% if variant in ["almalinux", "alpine", "amazon", "cloudlinux", "eurolinux", ++ "fedora", "miraclelinux", "openEuler", "openmandriva", "rocky", "virtuozzo"] or is_rhel %} ++{% if is_rhel %} + mount_default_fields: [~, ~, 'auto', 'defaults,nofail,x-systemd.requires=cloud-init.service,_netdev', '0', '2'] + {% else %} + mount_default_fields: [~, ~, 'auto', 'defaults,nofail', '0', '2'] +@@ -70,7 +71,7 @@ network: + config: disabled + {% endif %} + +-{% if variant == "rhel" %} ++{% if is_rhel %} + # Default redhat settings: + ssh_deletekeys: true + ssh_genkeytypes: ['rsa', 'ecdsa', 'ed25519'] +@@ -119,16 +120,16 @@ cloud_config_modules: + {% endif %} + {% if variant not in ["photon"] %} + - ssh-import-id +-{% if variant not in ["rhel"] %} ++{% if not is_rhel %} + - keyboard + {% endif %} + - locale + {% endif %} + - set-passwords +-{% if variant in ["rhel"] %} ++{% if is_rhel %} + - rh_subscription + {% endif %} +-{% if variant in ["rhel", "fedora", "photon"] %} ++{% if variant in ["fedora", "openmandriva", "photon"] or is_rhel %} + {% if variant not in ["photon"] %} + - spacewalk + {% endif %} +@@ -193,9 +194,9 @@ cloud_final_modules: + # (not accessible to handlers/transforms) + system_info: + # This will affect which distro class gets used +-{% if variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "debian", ++{% if variant in ["almalinux", "alpine", "amazon", "arch", "cloudlinux", "debian", + "eurolinux", "fedora", "freebsd", "gentoo", "netbsd", "miraclelinux", "openbsd", "openEuler", +- "photon", "rhel", "rocky", "suse", "ubuntu", "virtuozzo"] %} ++ "openmandriva", "photon", "rocky", "suse", "ubuntu", "virtuozzo"] or is_rhel %} + distro: {{ variant }} + {% elif variant in ["dragonfly"] %} + distro: dragonflybsd +@@ -248,15 +249,15 @@ system_info: + primary: http://ports.ubuntu.com/ubuntu-ports + security: http://ports.ubuntu.com/ubuntu-ports + ssh_svcname: ssh +-{% elif variant in ["almalinux", "alpine", "amazon", "arch", "centos", "cloudlinux", "eurolinux", +- "fedora", "gentoo", "miraclelinux", "openEuler", "rhel", "rocky", "suse", "virtuozzo"] %} ++{% elif variant in ["almalinux", "alpine", "amazon", "arch", "cloudlinux", "eurolinux", ++ "fedora", "gentoo", "miraclelinux", "openEuler", "openmandriva", "rocky", "suse", "virtuozzo"] or is_rhel %} + # Default user name + that default users groups (if added/used) + default_user: + {% if variant == "amazon" %} + name: ec2-user + lock_passwd: True + gecos: EC2 Default User +-{% elif variant == "rhel" %} ++{% elif is_rhel %} + name: cloud-user + lock_passwd: true + gecos: Cloud User +@@ -275,7 +276,7 @@ system_info: + groups: [adm, sudo] + {% elif variant == "arch" %} + groups: [wheel, users] +-{% elif variant == "rhel" %} ++{% elif is_rhel %} + groups: [adm, systemd-journal] + {% else %} + groups: [wheel, adm, systemd-journal] +diff --git a/tests/unittests/test_render_cloudcfg.py b/tests/unittests/test_render_cloudcfg.py +index 9f95d448..1a6e2715 100644 +--- a/tests/unittests/test_render_cloudcfg.py ++++ b/tests/unittests/test_render_cloudcfg.py +@@ -69,6 +69,7 @@ class TestRenderCloudCfg: + "amazon": "ec2-user", + "debian": "ubuntu", + "rhel": "cloud-user", ++ "centos": "cloud-user", + "unknown": "ubuntu", + } + default_user = system_cfg["system_info"]["default_user"]["name"] +-- +2.37.3 + diff --git a/SPECS/cloud-init.spec b/SPECS/cloud-init.spec index 58a1b58..2658782 100644 --- a/SPECS/cloud-init.spec +++ b/SPECS/cloud-init.spec @@ -6,7 +6,7 @@ Name: cloud-init Version: 22.1 -Release: 5%{?dist} +Release: 8%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base @@ -45,6 +45,12 @@ Patch13: ci-Revert-Add-native-NetworkManager-support-1224.patch # For bz#2104393 - [RHEL-8.7]Failed to config static IP and IPv6 according to VMware Customization Config File # For bz#2098624 - [RHEL-8.7] IPv6 not workable when cloud-init configure network using NM keyfiles Patch14: ci-Revert-Use-Network-Manager-and-Netplan-as-default-re.patch +# For bz#2115576 - cloud-init configures user "centos" or "rhel" instead of "cloud-user" with cloud-init-22.1 +Patch15: ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch +# For bz#2151861 - [RHEL-8] Ensure network ready before cloud-init service runs on RHEL +Patch16: ci-Ensure-network-ready-before-cloud-init-service-runs-.patch +# For bz#2162258 - systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8] +Patch17: ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch BuildArch: noarch @@ -230,6 +236,21 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Mon Jan 30 2023 Camilla Conte - 22.1-8 +- ci-cc_set_hostname-ignore-var-lib-cloud-data-set-hostna.patch [bz#2162258] +- Resolves: bz#2162258 + (systemd[1]: Failed to start Initial cloud-init job after reboot system via sysrq 'b' [RHEL-8]) + +* Wed Dec 28 2022 Camilla Conte - 22.1-7 +- ci-Ensure-network-ready-before-cloud-init-service-runs-.patch [bz#2151861] +- Resolves: bz#2151861 + ([RHEL-8] Ensure network ready before cloud-init service runs on RHEL) + +* Mon Oct 17 2022 Jon Maloy - 22.1-6 +- ci-cloud.cfg.tmpl-make-sure-centos-settings-are-identic.patch [bz#2115576] +- Resolves: bz#2115576 + (cloud-init configures user "centos" or "rhel" instead of "cloud-user" with cloud-init-22.1) + * Wed Aug 17 2022 Jon Maloy - 22.1-5 - ci-Revert-Add-native-NetworkManager-support-1224.patch [bz#2107464 bz#2110066 bz#2117526 bz#2104393 bz#2098624] - ci-Revert-Use-Network-Manager-and-Netplan-as-default-re.patch [bz#2107464 bz#2110066 bz#2117526 bz#2104393 bz#2098624]