From a7a28cce9f768de4f520a114f3937f2e62ca0bed Mon Sep 17 00:00:00 2001 From: Mike Svendsen Date: Wed, 2 Jun 2021 21:16:28 -0500 Subject: [PATCH 1/2] Fix queue attribute comparison --- plugins/modules/sqs_queue.py | 2 +- .../targets/sqs_queue/tasks/main.yml | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/plugins/modules/sqs_queue.py b/plugins/modules/sqs_queue.py index b76cdb31410..50a0b4a4626 100644 --- a/plugins/modules/sqs_queue.py +++ b/plugins/modules/sqs_queue.py @@ -377,7 +377,7 @@ def update_sqs_queue(module, client, queue_url): new_value = str(new_value).lower() value = str(value).lower() - if new_value == value: + if str(new_value) == str(value): continue # Boto3 expects strings diff --git a/tests/integration/targets/sqs_queue/tasks/main.yml b/tests/integration/targets/sqs_queue/tasks/main.yml index 483f17bb298..f557085e58f 100644 --- a/tests/integration/targets/sqs_queue/tasks/main.yml +++ b/tests/integration/targets/sqs_queue/tasks/main.yml @@ -67,6 +67,50 @@ - create_result.policy.Version == "2012-10-17" - create_result.policy.Statement[0].Effect == "Allow" - create_result.policy.Statement[0].Action == "*" + - name: Test idempotentcy + sqs_queue: + name: "{{ create_result.name }}" + default_visibility_timeout: 900 + delivery_delay: 900 + maximum_message_size: 9009 + message_retention_period: 900 + receive_message_wait_time: 10 + policy: + Version: "2012-10-17" + Statement: + Effect: Allow + Action: "*" + register: create_result + - name: Assert nothing changed + assert: + that: + - not create_result.changed + - name: Test update + sqs_queue: + name: "{{ create_result.name }}" + default_visibility_timeout: 899 + delivery_delay: 899 + maximum_message_size: 9008 + message_retention_period: 899 + receive_message_wait_time: 9 + policy: + Version: "2012-10-17" + Statement: + Effect: Allow + Action: "*" + register: create_result + - name: Assert queue updated with configuration + assert: + that: + - create_result.changed + - create_result.default_visibility_timeout == 899 + - create_result.delivery_delay == 899 + - create_result.maximum_message_size == 9008 + - create_result.message_retention_period == 899 + - create_result.receive_message_wait_time == 9 + - create_result.policy.Version == "2012-10-17" + - create_result.policy.Statement[0].Effect == "Allow" + - create_result.policy.Statement[0].Action == "*" always: - name: Cleaning up queue sqs_queue: From bc1372a159f3c7de2eb77f06ecef47b6e22ba647 Mon Sep 17 00:00:00 2001 From: Mike Svendsen Date: Wed, 2 Jun 2021 21:29:04 -0500 Subject: [PATCH 2/2] Add changelog entry --- changelogs/592-sqs_queue-idempotent.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/592-sqs_queue-idempotent.yml diff --git a/changelogs/592-sqs_queue-idempotent.yml b/changelogs/592-sqs_queue-idempotent.yml new file mode 100644 index 00000000000..94bd5ef2388 --- /dev/null +++ b/changelogs/592-sqs_queue-idempotent.yml @@ -0,0 +1,2 @@ +bugfixes: +- sqs_queue - fix queue attribute comparison to make module idempotent (https://github.com/ansible-collections/community.aws/pull/592).