From 0aab250fbc593339e075fd2e1e6a3a92c0bfda7c Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 29 Apr 2025 16:51:22 +0200 Subject: [PATCH] dnf5: avoid generating excessive history entries (#85065) Fixes #85046 (cherry picked from commit cff49a62ecb0857c23de60cbb9e6b021dd017bf7) --- changelogs/fragments/85046-dnf5-history-entries.yml | 2 ++ lib/ansible/modules/dnf5.py | 2 +- test/integration/targets/dnf/tasks/repo.yml | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/85046-dnf5-history-entries.yml diff --git a/changelogs/fragments/85046-dnf5-history-entries.yml b/changelogs/fragments/85046-dnf5-history-entries.yml new file mode 100644 index 00000000000..917b48d83d3 --- /dev/null +++ b/changelogs/fragments/85046-dnf5-history-entries.yml @@ -0,0 +1,2 @@ +bugfixes: + - dnf5 - avoid generating excessive transaction entries in the dnf5 history (https://github.com/ansible/ansible/issues/85046) diff --git a/lib/ansible/modules/dnf5.py b/lib/ansible/modules/dnf5.py index 5df5179fe27..c1a03f0ec62 100644 --- a/lib/ansible/modules/dnf5.py +++ b/lib/ansible/modules/dnf5.py @@ -797,7 +797,7 @@ class Dnf5Module(YumDnf): if self.module.check_mode: if results: msg = "Check mode: No changes made, but would have if not in check mode" - else: + elif changed: transaction.download() if not self.download_only: transaction.set_description("ansible dnf5 module") diff --git a/test/integration/targets/dnf/tasks/repo.yml b/test/integration/targets/dnf/tasks/repo.yml index 6e1b78252ff..4c758883119 100644 --- a/test/integration/targets/dnf/tasks/repo.yml +++ b/test/integration/targets/dnf/tasks/repo.yml @@ -19,6 +19,9 @@ assert: that: - "'results' in dnf_result" + + - shell: dnf history list | wc -l + register: dnf_history_lines_before # ============================================================================ - name: Install dinginessentail-1.0-1 again dnf: @@ -40,6 +43,13 @@ assert: that: - "'msg' in dnf_result" + + - shell: dnf history list | wc -l + register: dnf_history_lines_after + + - assert: + that: + - dnf_history_lines_before.stdout == dnf_history_lines_after.stdout # ============================================================================ - name: Install dinginessentail again (noop, module is idempotent) dnf: