From f4e81e914e50c3190145c27a9e2464c190fcd7ec Mon Sep 17 00:00:00 2001 From: Julien Simbola Date: Fri, 12 Aug 2022 16:20:27 +0200 Subject: [PATCH] fix ignore_nonexistent_bucket bug for listing (#966) (#967) fix ignore_nonexistent_bucket bug for listing (#966) SUMMARY remove duplicated use of bucket_check() and reuse bucketrtn instead Fixes #966 ISSUE TYPE Bugfix Pull Request COMPONENT NAME s3_object ADDITIONAL INFORMATION Reviewed-by: Mark Chappell --- changelogs/fragments/966-ignore_nonexistent_bucket_list.yml | 2 ++ plugins/modules/s3_object.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/966-ignore_nonexistent_bucket_list.yml diff --git a/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml b/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml new file mode 100644 index 00000000000..8fc2c14d491 --- /dev/null +++ b/changelogs/fragments/966-ignore_nonexistent_bucket_list.yml @@ -0,0 +1,2 @@ +bugfixes: +- s3_object - also use ``ignore_nonexistent_bucket`` when listing a bucket (https://github.com/ansible-collections/amazon.aws/issues/966). diff --git a/plugins/modules/s3_object.py b/plugins/modules/s3_object.py index dcefbcae674..7f979719eef 100644 --- a/plugins/modules/s3_object.py +++ b/plugins/modules/s3_object.py @@ -1168,10 +1168,9 @@ def main(): # Support for listing a set of keys if mode == 'list': - exists = bucket_check(module, s3, bucket) # If the bucket does not exist then bail out - if not exists: + if not bucketrtn: module.fail_json(msg="Target bucket (%s) cannot be found" % bucket) list_keys(module, s3, bucket, prefix, marker, max_keys)