Skip to content

Commit

Permalink
delete all buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed May 7, 2021
1 parent df23570 commit d12847a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 45 deletions.
22 changes: 2 additions & 20 deletions tests/integration/targets/aws_s3/tasks/copy_object.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,7 @@
- "copy_idempotency.msg == 'ETag from source and destination are the same'"

always:
- name: remove uploaded files
aws_s3:
bucket: "{{ copy_bucket.dst }}"
mode: delobj
object: destination.txt
ignore_errors: yes

- name: remove uploaded files
aws_s3:
bucket: "{{ copy_bucket.src }}"
mode: delobj
object: source.txt
ignore_errors: yes

- name: delete bucket created
aws_s3:
bucket: "{{ item }}"
mode: delete
- include_tasks: delete_bucket.yml
with_items:
- "{{ copy_bucket.src }}"
- "{{ copy_bucket.dst }}"
ignore_errors: yes
- "{{ copy_bucket.src }}"
24 changes: 24 additions & 0 deletions tests/integration/targets/aws_s3/tasks/delete_bucket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: delete bucket at the end of Integration tests
block:
- name: list bucket object
aws_s3:
bucket: "{{ item }}"
mode: list
register: objects
ignore_errors: true

- name: remove objects from bucket
aws_s3:
bucket: "{{ item }}"
mode: delobj
object: "{{ obj }}"
with_items: "{{ objects.s3_keys }}"
loop_control:
loop_var: obj
ignore_errors: true

- name: delete the bucket
aws_s3:
bucket: "{{ item }}"
mode: delete
ignore_errors: yes
29 changes: 4 additions & 25 deletions tests/integration/targets/aws_s3/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -642,35 +642,14 @@
- include_tasks: copy_object.yml

always:
- name: remove uploaded files
aws_s3:
bucket: "{{ bucket_name }}"
mode: delobj
object: "{{ item }}"
loop:
- hello.txt
- delete.txt
- delete_encrypt.txt
- delete_encrypt_kms.txt
- put-content.txt
- put-template.txt
- put-binary.txt
ignore_errors: yes

- name: delete temporary files
file:
state: absent
path: "{{ tmpdir.path }}"
ignore_errors: yes

- name: delete the bucket
aws_s3:
bucket: "{{ bucket_name }}"
mode: delete
ignore_errors: yes

- name: delete the dot bucket
aws_s3:
bucket: "{{ bucket_name | hash('md5') + '.bucket' }}"
mode: delete
ignore_errors: yes
- include_tasks: delete_bucket.yml
with_items:
- "{{ bucket_name }}"
- "{{ bucket_name | hash('md5') + '.bucket' }}"

0 comments on commit d12847a

Please sign in to comment.