From 1228e58b6c8cb6078d725ec60beb87e6bf3796c3 Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Thu, 5 Oct 2023 16:27:11 -0500 Subject: [PATCH] Honor rpm aliases with whatprovides Fixes #494 When using an rpm-ostree based system, the rhel_rpm_ostree module needs to honor rpm aliases. Using whatprovides in the query honors that. Fix error output formatting for rhel_rpm_ostree Signed-off-by: Adam Miller --- plugins/modules/rhel_rpm_ostree.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/rhel_rpm_ostree.py b/plugins/modules/rhel_rpm_ostree.py index 0976e02..bc68161 100644 --- a/plugins/modules/rhel_rpm_ostree.py +++ b/plugins/modules/rhel_rpm_ostree.py @@ -77,7 +77,7 @@ from ansible.module_utils._text import to_text def locally_installed(module, pkgname): - (rc, out, err) = module.run_command('{0} -q {1}'.format(module.get_bin_path("rpm"), pkgname).split()) + (rc, _, _) = module.run_command('{0} -q --whatprovides {1}'.format(module.get_bin_path("rpm"), pkgname).split()) return (rc == 0) @@ -97,9 +97,9 @@ def rpm_ostree_transaction(module): module.exit_json(msg="No changes made.") else: if module.params['state'] in ['present', 'installed', 'latest']: - module.fail_json(msg="The following packages are absent in the currently booted rpm-ostree commit: %s" ' '.join(pkgs)) + module.fail_json(msg="The following packages are absent in the currently booted rpm-ostree commit: {}".format(' '.join(pkgs))) else: - module.fail_json(msg="The following packages are present in the currently booted rpm-ostree commit: %s" ' '.join(pkgs)) + module.fail_json(msg="The following packages are present in the currently booted rpm-ostree commit: {}".format(' '.join(pkgs))) def main():