From c9f0bf30aa87d1f31a770228b73bdd41ee6a296e Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 5 Jan 2024 13:59:17 +0100 Subject: [PATCH 1/2] remote.py: Formatted with black Ticket: None Changelog: None Signed-off-by: Lars Erik Wik --- cf_remote/remote.py | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/cf_remote/remote.py b/cf_remote/remote.py index 07220a5..4b46718 100644 --- a/cf_remote/remote.py +++ b/cf_remote/remote.py @@ -130,15 +130,32 @@ def get_package_tags(os_release=None, redhat_release=None): # Add tags with version number first, to filter by them first: tags.append(platform_tag) # Example: ubuntu16 - if distro == "centos" or distro == "rhel" or distro == "ol" or distro == "rocky" or distro == "almalinux": + if ( + distro == "centos" + or distro == "rhel" + or distro == "ol" + or distro == "rocky" + or distro == "almalinux" + ): tags.append("el" + major) # Then add more generic tags (lower priority): tags.append(distro) # Example: ubuntu - if distro == "centos" or distro == "ol" or distro == "rocky" or distro == "almalinux": + if ( + distro == "centos" + or distro == "ol" + or distro == "rocky" + or distro == "almalinux" + ): tags.append("rhel") - if distro == "centos" or distro == "rhel" or distro == "ol" or distro == "rocky" or distro == "almalinux": + if ( + distro == "centos" + or distro == "rhel" + or distro == "ol" + or distro == "rocky" + or distro == "almalinux" + ): tags.append("el") elif redhat_release is not None: # Examples: @@ -234,10 +251,16 @@ def install_package(host, pkg, data, *, connection=None): # generally this "else" is for rpm packages if "yum" in data["bin"]: output = ssh_sudo(connection, "yum -y install {}".format(pkg), True) - elif "zypper" in data["bin"]: # suse case - output = ssh_sudo(connection, "zypper install -y --allow-unsigned-rpm {}".format(pkg), True) + elif "zypper" in data["bin"]: # suse case + output = ssh_sudo( + connection, + "zypper install -y --allow-unsigned-rpm {}".format(pkg), + True, + ) else: - log.error("Don't know how to install rpm package. No yum or zypper in PATH.") + log.error( + "Don't know how to install rpm package. No yum or zypper in PATH." + ) if output is None: log.error("Installation failed on '{}'".format(host)) From 148c1f9f445bd33a4461d61abbae6bfe9d032938 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Fri, 5 Jan 2024 14:01:23 +0100 Subject: [PATCH 2/2] Removed the --allow-unsigned-rpm when installing on SUSE 12 SUSE 12-SP5 does not support this option, and it installed fine without it. Ticket: None Changelog: None Signed-off-by: Lars Erik Wik --- cf_remote/remote.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cf_remote/remote.py b/cf_remote/remote.py index 4b46718..6ae3c24 100644 --- a/cf_remote/remote.py +++ b/cf_remote/remote.py @@ -252,10 +252,14 @@ def install_package(host, pkg, data, *, connection=None): if "yum" in data["bin"]: output = ssh_sudo(connection, "yum -y install {}".format(pkg), True) elif "zypper" in data["bin"]: # suse case + allow_unsigned = ( + "" + if data["os_release"]["VERSION"] + == "12-SP5" # Does not support the option + else "--allow-unsigned-rpm" + ) output = ssh_sudo( - connection, - "zypper install -y --allow-unsigned-rpm {}".format(pkg), - True, + connection, "zypper install -y {} {}".format(allow_unsigned, pkg), True ) else: log.error(