diff --git a/SOURCES/ci-Adding-BOOTPROTO-dhcp-to-render-sysconfig-dhcp6-stat.patch b/SOURCES/ci-Adding-BOOTPROTO-dhcp-to-render-sysconfig-dhcp6-stat.patch new file mode 100644 index 0000000..c31b4b2 --- /dev/null +++ b/SOURCES/ci-Adding-BOOTPROTO-dhcp-to-render-sysconfig-dhcp6-stat.patch @@ -0,0 +1,58 @@ +From 8a7d21fa739901bad847294004266dba76c027af Mon Sep 17 00:00:00 2001 +From: Eduardo Otubo +Date: Tue, 1 Dec 2020 15:51:47 +0100 +Subject: [PATCH 2/4] Adding BOOTPROTO = dhcp to render sysconfig dhcp6 + stateful on RHEL (#685) + +RH-Author: Eduardo Terrell Ferrari Otubo (eterrell) +RH-MergeRequest: 25: Adding BOOTPROTO = dhcp to render sysconfig dhcp6 stateful on RHEL (#685) +RH-Commit: [1/1] b7304323096b1e40287950e44cf7aa3cdb4ba99e (eterrell/cloud-init) +RH-Bugzilla: 1859695 + +BOOTPROTO needs to be set to 'dhcp' on RHEL so NetworkManager can +properly acquire ipv6 address. + +rhbz: #1859695 + +Signed-off-by: Eduardo Otubo + +Co-authored-by: Daniel Watkins +Co-authored-by: Scott Moser +--- + cloudinit/net/sysconfig.py | 6 ++++++ + tests/unittests/test_net.py | 2 +- + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py +index 078636a4..94801a93 100644 +--- a/cloudinit/net/sysconfig.py ++++ b/cloudinit/net/sysconfig.py +@@ -391,6 +391,12 @@ class Renderer(renderer.Renderer): + # Only IPv6 is DHCP, IPv4 may be static + iface_cfg['BOOTPROTO'] = 'dhcp6' + iface_cfg['DHCLIENT6_MODE'] = 'managed' ++ # only if rhel AND dhcpv6 stateful ++ elif (flavor == 'rhel' and ++ subnet_type == 'ipv6_dhcpv6-stateful'): ++ iface_cfg['BOOTPROTO'] = 'dhcp' ++ iface_cfg['DHCPV6C'] = True ++ iface_cfg['IPV6INIT'] = True + else: + iface_cfg['IPV6INIT'] = True + # Configure network settings using DHCPv6 +diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py +index c0337459..bcd261db 100644 +--- a/tests/unittests/test_net.py ++++ b/tests/unittests/test_net.py +@@ -1359,7 +1359,7 @@ NETWORK_CONFIGS = { + }, + 'expected_sysconfig_rhel': { + 'ifcfg-iface0': textwrap.dedent("""\ +- BOOTPROTO=none ++ BOOTPROTO=dhcp + DEVICE=iface0 + DHCPV6C=yes + IPV6INIT=yes +-- +2.18.4 + 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..aeaa342 --- /dev/null +++ b/SOURCES/ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch @@ -0,0 +1,61 @@ +From d3889c4645a1319c3d677006164b618ee53f4c8b Mon Sep 17 00:00:00 2001 +From: Eduardo Otubo +Date: Mon, 7 Dec 2020 14:23:22 +0100 +Subject: [PATCH 3/4] 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 +--- + 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 05add077..e281c0cf 100644 +--- a/rhel/systemd/cloud-final.service ++++ b/rhel/systemd/cloud-final.service +@@ -11,8 +11,11 @@ ExecStart=/usr/bin/cloud-init modules --mode=final + RemainAfterExit=yes + TimeoutSec=0 + KillMode=process +-ExecStartPost=/bin/echo "trying to reload or restart NetworkManager.service" +-ExecStartPost=/usr/bin/systemctl try-reload-or-restart NetworkManager.service ++# Restart NetworkManager if it is present and running. ++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.18.4 + diff --git a/SOURCES/ci-ssh_util-handle-non-default-AuthorizedKeysFile-confi.patch b/SOURCES/ci-ssh_util-handle-non-default-AuthorizedKeysFile-confi.patch new file mode 100644 index 0000000..5fbcb0c --- /dev/null +++ b/SOURCES/ci-ssh_util-handle-non-default-AuthorizedKeysFile-confi.patch @@ -0,0 +1,98 @@ +From b84a1e6d246bbb758f0530038612bd18eff71767 Mon Sep 17 00:00:00 2001 +From: Eduardo Otubo +Date: Tue, 8 Dec 2020 13:27:22 +0100 +Subject: [PATCH 4/4] ssh_util: handle non-default AuthorizedKeysFile config + (#586) + +RH-Author: Eduardo Terrell Ferrari Otubo (eterrell) +RH-MergeRequest: 28: ssh_util: handle non-default AuthorizedKeysFile config (#586) +RH-Commit: [1/1] f7ce396e3002c53a3504e653b58810efb956aa26 (eterrell/cloud-init) +RH-Bugzilla: 1862967 + +commit b0e73814db4027dba0b7dc0282e295b7f653325c +Author: Eduardo Otubo +Date: Tue Oct 20 18:04:59 2020 +0200 + + ssh_util: handle non-default AuthorizedKeysFile config (#586) + + The following commit merged all ssh keys into a default user file + `~/.ssh/authorized_keys` in sshd_config had multiple files configured for + AuthorizedKeysFile: + + commit f1094b1a539044c0193165a41501480de0f8df14 + Author: Eduardo Otubo + Date: Thu Dec 5 17:37:35 2019 +0100 + + Multiple file fix for AuthorizedKeysFile config (#60) + + This commit ignored the case when sshd_config would have a single file for + AuthorizedKeysFile, but a non default configuration, for example + `~/.ssh/authorized_keys_foobar`. In this case cloud-init would grab all keys + from this file and write a new one, the default `~/.ssh/authorized_keys` + causing the bug. + + rhbz: #1862967 + + Signed-off-by: Eduardo Otubo + +Signed-off-by: Eduardo Otubo +--- + cloudinit/ssh_util.py | 6 +++--- + tests/unittests/test_sshutil.py | 6 +++--- + 2 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/cloudinit/ssh_util.py b/cloudinit/ssh_util.py +index c08042d6..d5113996 100644 +--- a/cloudinit/ssh_util.py ++++ b/cloudinit/ssh_util.py +@@ -262,13 +262,13 @@ def extract_authorized_keys(username, sshd_cfg_file=DEF_SSHD_CFG): + + except (IOError, OSError): + # Give up and use a default key filename +- auth_key_fns[0] = default_authorizedkeys_file ++ auth_key_fns.append(default_authorizedkeys_file) + util.logexc(LOG, "Failed extracting 'AuthorizedKeysFile' in SSH " + "config from %r, using 'AuthorizedKeysFile' file " + "%r instead", DEF_SSHD_CFG, auth_key_fns[0]) + +- # always store all the keys in the user's private file +- return (default_authorizedkeys_file, parse_authorized_keys(auth_key_fns)) ++ # always store all the keys in the first file configured on sshd_config ++ return (auth_key_fns[0], parse_authorized_keys(auth_key_fns)) + + + def setup_user_keys(keys, username, options=None): +diff --git a/tests/unittests/test_sshutil.py b/tests/unittests/test_sshutil.py +index fd1d1bac..88a111e3 100644 +--- a/tests/unittests/test_sshutil.py ++++ b/tests/unittests/test_sshutil.py +@@ -593,7 +593,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase): + fpw.pw_name, sshd_config) + content = ssh_util.update_authorized_keys(auth_key_entries, []) + +- self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn) ++ self.assertEqual(authorized_keys, auth_key_fn) + self.assertTrue(VALID_CONTENT['rsa'] in content) + self.assertTrue(VALID_CONTENT['dsa'] in content) + +@@ -610,7 +610,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase): + sshd_config = self.tmp_path('sshd_config') + util.write_file( + sshd_config, +- "AuthorizedKeysFile %s %s" % (authorized_keys, user_keys) ++ "AuthorizedKeysFile %s %s" % (user_keys, authorized_keys) + ) + + (auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys( +@@ -618,7 +618,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase): + ) + content = ssh_util.update_authorized_keys(auth_key_entries, []) + +- self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn) ++ self.assertEqual(user_keys, auth_key_fn) + self.assertTrue(VALID_CONTENT['rsa'] in content) + self.assertTrue(VALID_CONTENT['dsa'] in content) + +-- +2.18.4 + diff --git a/SPECS/cloud-init.spec b/SPECS/cloud-init.spec index 9ff9ace..da7cc88 100644 --- a/SPECS/cloud-init.spec +++ b/SPECS/cloud-init.spec @@ -6,7 +6,7 @@ Name: cloud-init Version: 20.3 -Release: 5%{?dist} +Release: 7%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base @@ -26,6 +26,12 @@ Patch8: ci-Explicit-set-IPV6_AUTOCONF-and-IPV6_FORCE_ACCEPT_RA-.patch Patch9: ci-Add-config-modules-for-controlling-IBM-PowerVM-RMC.-.patch # For bz#1881462 - [rhel8][cloud-init] ifup bond0.504 Error: Connection activation failed: No suitable device found for this connection Patch10: ci-network-Fix-type-and-respect-name-when-rendering-vla.patch +# For bz#1859695 - [Cloud-init] DHCPv6 assigned address is not added to VM's interface +Patch11: ci-Adding-BOOTPROTO-dhcp-to-render-sysconfig-dhcp6-stat.patch +# For bz#1898943 - [rhel-8]cloud-final.service fails if NetworkManager not installed. +Patch12: ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch +# For bz#1862967 - [cloud-init]Customize ssh AuthorizedKeysFile causes login failure +Patch13: ci-ssh_util-handle-non-default-AuthorizedKeysFile-confi.patch BuildArch: noarch @@ -98,6 +104,8 @@ sed -i -e 's|#!/usr/bin/env python|#!/usr/bin/env python3|' \ python3 tools/render-cloudcfg --variant fedora > $RPM_BUILD_ROOT/%{_sysconfdir}/cloud/cloud.cfg +sed -i "s,@@PACKAGED_VERSION@@,%{version}-%{release}," $RPM_BUILD_ROOT/%{python3_sitelib}/cloudinit/version.py + mkdir -p $RPM_BUILD_ROOT/var/lib/cloud # /run/cloud-init needs a tmpfiles.d entry @@ -127,9 +135,10 @@ chmod 755 $RPM_BUILD_ROOT/usr/lib/systemd/system-generators/cloud-init-generator cp -p tools/ds-identify $RPM_BUILD_ROOT%{_libexecdir}/%{name}/ds-identify # installing man pages -mkdir -p %{buildroot}/usr/local/man/man1/ +mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1/ for man in cloud-id.1 cloud-init.1 cloud-init-per.1; do - cp doc/man/${man} %{buildroot}/usr/local/man/man1/ + install -c -m 0644 doc/man/${man} ${RPM_BUILD_ROOT}%{_mandir}/man1/${man} + chmod -x ${RPM_BUILD_ROOT}%{_mandir}/man1/* done %clean @@ -199,9 +208,7 @@ fi %{_libexecdir}/%{name} %{_bindir}/cloud-init* %doc %{_datadir}/doc/%{name} -%doc /usr/local/man/man1/cloud-id.1 -%doc /usr/local/man/man1/cloud-init.1 -%doc /usr/local/man/man1/cloud-init-per.1 +%{_mandir}/man1/* %dir %verify(not mode) /run/cloud-init %dir /var/lib/cloud /etc/NetworkManager/dispatcher.d/cloud-init-azure-hook @@ -216,6 +223,25 @@ fi %config(noreplace) %{_sysconfdir}/rsyslog.d/21-cloudinit.conf %changelog +* Tue Jan 05 2021 Miroslav Rezanina - 20.3-7.el8 +- ci-Report-full-specific-version-with-cloud-init-version.patch [bz#1898949] +- Resolves: bz#1898949 + (cloud-init should report full specific full version with "cloud-init --version") + +* Mon Dec 14 2020 Miroslav Rezanina - 20.3-6.el8 +- ci-Installing-man-pages-in-the-correct-place-with-corre.patch [bz#1612573] +- ci-Adding-BOOTPROTO-dhcp-to-render-sysconfig-dhcp6-stat.patch [bz#1859695] +- ci-Fix-unit-failure-of-cloud-final.service-if-NetworkMa.patch [bz#1898943] +- ci-ssh_util-handle-non-default-AuthorizedKeysFile-confi.patch [bz#1862967] +- Resolves: bz#1612573 + (Man page scan results for cloud-init) +- Resolves: bz#1859695 + ([Cloud-init] DHCPv6 assigned address is not added to VM's interface) +- Resolves: bz#1898943 + ([rhel-8]cloud-final.service fails if NetworkManager not installed.) +- Resolves: bz#1862967 + ([cloud-init]Customize ssh AuthorizedKeysFile causes login failure) + * Fri Nov 27 2020 Miroslav Rezanina - 20.3-5.el8 - ci-network-Fix-type-and-respect-name-when-rendering-vla.patch [bz#1881462] - Resolves: bz#1881462