diff --git a/changelogs/fragments/deb822_repo_idem.yml b/changelogs/fragments/deb822_repo_idem.yml new file mode 100644 index 00000000000..5f60a78f75f --- /dev/null +++ b/changelogs/fragments/deb822_repo_idem.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - deb822_repository - handle idempotency if the order of parameters is changed (https://github.com/ansible/ansible/issues/82454). diff --git a/lib/ansible/modules/deb822_repository.py b/lib/ansible/modules/deb822_repository.py index 980884f07f2..9334c451bd3 100644 --- a/lib/ansible/modules/deb822_repository.py +++ b/lib/ansible/modules/deb822_repository.py @@ -500,7 +500,7 @@ def main(): deb822 = Deb822() signed_by_filename = None - for key, value in params.items(): + for key, value in sorted(params.items()): if value is None: continue diff --git a/test/integration/targets/deb822_repository/tasks/test.yml b/test/integration/targets/deb822_repository/tasks/test.yml index 4911bb92a5e..345ccb7ad8d 100644 --- a/test/integration/targets/deb822_repository/tasks/test.yml +++ b/test/integration/targets/deb822_repository/tasks/test.yml @@ -53,6 +53,19 @@ date_max_future: 10 register: deb822_create_1_idem +- name: Create deb822 repo (changed order of parameters) idempotency + deb822_repository: + uris: http://us.archive.ubuntu.com/ubuntu + name: ansible-test focal archive + date_max_future: 10 + components: + - main + - restricted + suites: + - focal + - focal-updates + register: deb822_create_2_idem + - name: Create deb822 repo - check_mode deb822_repository: name: ansible-test focal archive @@ -97,18 +110,19 @@ - deb822_create_1.repo|trim == focal_archive_expected - deb822_create_1_idem is not changed + - deb822_create_2_idem is not changed - deb822_create_1_mode is changed - deb822_create_1_stat_1.stat.mode == '0644' - deb822_create_1_stat_2.stat.mode == '0600' vars: focal_archive_expected: |- - X-Repolib-Name: ansible-test focal archive - URIs: http://us.archive.ubuntu.com/ubuntu - Suites: focal focal-updates Components: main restricted Date-Max-Future: 10 + X-Repolib-Name: ansible-test focal archive + Suites: focal focal-updates Types: deb + URIs: http://us.archive.ubuntu.com/ubuntu - name: Remove repos deb822_repository: @@ -177,11 +191,8 @@ 'BEGIN' not in signed_by_url.repo vars: signed_by_inline_expected: |- - X-Repolib-Name: ansible-test - Types: deb - URIs: https://deb.debian.org - Suites: stable Components: main contrib non-free + X-Repolib-Name: ansible-test Signed-By: -----BEGIN PGP PUBLIC KEY BLOCK----- . @@ -192,6 +203,9 @@ 3bHcln8DMpIJVXht78sL =IE0r -----END PGP PUBLIC KEY BLOCK----- + Suites: stable + Types: deb + URIs: https://deb.debian.org - name: remove ansible-test repo deb822_repository: