From c6849a34647eb8c2c92cc0659de769eeee8fce4c Mon Sep 17 00:00:00 2001 From: amblina Date: Tue, 28 Feb 2017 20:36:55 +0000 Subject: [PATCH] S3 object parameter and bucket deletion exclusive (#21830) Fixes ansible#21796 Prevent users from deleting buckets rather than objects by making object parameter and mode=delobj mutually exclusive in task. https://github.com/ansible/ansible/issues/21796 --- lib/ansible/modules/cloud/amazon/s3.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/s3.py b/lib/ansible/modules/cloud/amazon/s3.py index 9425685c8bd..cacbccdbfd4 100644 --- a/lib/ansible/modules/cloud/amazon/s3.py +++ b/lib/ansible/modules/cloud/amazon/s3.py @@ -511,6 +511,10 @@ def main(): if module.params.get('object'): obj = module.params['object'] + # Bucket deletion does not require obj. Prevents ambiguity with delobj. + if obj and mode == "delete": + module.fail_json(msg='Parameter obj cannot be used with mode=delete') + # allow eucarc environment variables to be used if ansible vars aren't set if not s3_url and 'S3_URL' in os.environ: s3_url = os.environ['S3_URL']