From ae3f9b1faad6bf48cc9a8e478e208aefbd55e0db Mon Sep 17 00:00:00 2001 From: "David M. Lee" Date: Tue, 16 Mar 2021 08:20:57 -0500 Subject: [PATCH] Fix UnboundLocalError in sqs_queue (#389) * Fix UnboundLocalError in sqs_queue The variable `existing_value` is nowhere to be found, but looks like this might have been missed in a rename. Changing to `value`. Fixes #172 * integration test * changelog Co-authored-by: Mark Chappell --- .../389-sqs-queue-UnboundLocalError.yml | 2 ++ plugins/modules/sqs_queue.py | 2 +- .../targets/sqs_queue/tasks/main.yml | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/389-sqs-queue-UnboundLocalError.yml diff --git a/changelogs/fragments/389-sqs-queue-UnboundLocalError.yml b/changelogs/fragments/389-sqs-queue-UnboundLocalError.yml new file mode 100644 index 00000000000..8b1b371428f --- /dev/null +++ b/changelogs/fragments/389-sqs-queue-UnboundLocalError.yml @@ -0,0 +1,2 @@ +bugfixes: +- sqs_queue - fix UnboundLocalError when passing a boolean parameter (https://github.com/ansible-collections/community.aws/issues/172). diff --git a/plugins/modules/sqs_queue.py b/plugins/modules/sqs_queue.py index b0565c6c8d0..b76cdb31410 100644 --- a/plugins/modules/sqs_queue.py +++ b/plugins/modules/sqs_queue.py @@ -375,7 +375,7 @@ def update_sqs_queue(module, client, queue_url): if isinstance(new_value, bool): new_value = str(new_value).lower() - existing_value = str(existing_value).lower() + value = str(value).lower() if new_value == value: continue diff --git a/tests/integration/targets/sqs_queue/tasks/main.yml b/tests/integration/targets/sqs_queue/tasks/main.yml index b689c9eb2b9..483f17bb298 100644 --- a/tests/integration/targets/sqs_queue/tasks/main.yml +++ b/tests/integration/targets/sqs_queue/tasks/main.yml @@ -104,3 +104,25 @@ with_items: - { name: "{{ create_result.name }}" } - { name: "{{ dead_letter_queue.name }}" } + - name: Test FIFO queue + block: + - name: Creating FIFO queue + sqs_queue: + name: "{{ resource_prefix }}{{ 1000 | random }}" + queue_type: fifo + content_based_deduplication: yes + register: create_result + - name: Assert queue created with configuration + assert: + that: + - create_result.changed + always: + - name: Cleaning up queue + sqs_queue: + name: "{{ item.name }}" + state: absent + register: delete_result + retries: 3 + delay: 3 + with_items: + - { name: "{{ create_result.name }}" }