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: