diff options
author | Martin Krizek <martin.krizek@gmail.com> | 2023-04-06 20:19:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-06 13:19:27 -0500 |
commit | 856e0312ff2569882599134edd97a483e7ff6200 (patch) | |
tree | 3fc53915a59170813e2c35947665e750bca59c23 | |
parent | 13cdec1f46a0b43b4ca1cfac2771835986fc165f (diff) | |
download | ansible-856e0312ff2569882599134edd97a483e7ff6200.tar.gz |
dnf5: use the logs API to determine transaction problems (#80401) (#80433)
(cherry picked from commit 8d5c25023467e5039ffdf32dcc79eb7f171ebce5)
-rw-r--r-- | changelogs/fragments/dnf5-logs-api.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/dnf5.py | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/changelogs/fragments/dnf5-logs-api.yml b/changelogs/fragments/dnf5-logs-api.yml new file mode 100644 index 0000000000..10a19cc869 --- /dev/null +++ b/changelogs/fragments/dnf5-logs-api.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf5 - use the logs API to determine transaction problems diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py index 5e4b3d64ab..e25c79142d 100644 --- a/lib/ansible/modules/dnf5.py +++ b/lib/ansible/modules/dnf5.py @@ -629,11 +629,12 @@ class Dnf5Module(YumDnf): if transaction.get_problems(): failures = [] - for log in transaction.get_resolve_logs_as_strings(): - if log.startswith("No match for argument") and self.state in {"install", "present", "latest"}: - failures.append("No package {} available.".format(log.rsplit(' ', 1)[-1])) + for log_event in transaction.get_resolve_logs(): + if log_event.get_problem() == libdnf5.base.GoalProblem_NOT_FOUND and self.state in {"install", "present", "latest"}: + # NOTE dnf module compat + failures.append("No package {} available.".format(log_event.get_spec())) else: - failures.append(log) + failures.append(log_event.to_string()) if transaction.get_problems() & libdnf5.base.GoalProblem_SOLVER_ERROR != 0: msg = "Depsolve Error occurred" |