diff options
author | Joel Diaz <jdiaz@redhat.com> | 2018-02-01 17:21:10 +0000 |
---|---|---|
committer | Joel Diaz <jdiaz@redhat.com> | 2018-02-02 14:46:20 +0000 |
commit | f6afef5ca361340e31807919eeef255df75b17d3 (patch) | |
tree | 11e467ac3046468a92e50651d98ba2c36fa83d6d /roles | |
parent | 4fe88b001295566d49db1fe711870bf43c40c1ab (diff) | |
download | openshift-f6afef5ca361340e31807919eeef255df75b17d3.tar.gz openshift-f6afef5ca361340e31807919eeef255df75b17d3.tar.bz2 openshift-f6afef5ca361340e31807919eeef255df75b17d3.tar.xz openshift-f6afef5ca361340e31807919eeef255df75b17d3.zip |
add S3 bucket cleanup
Default to just cleaning out all the objects in the S3 bucket (IFF openshift_aws_create_s3 is 'true').
If you really, trully want to delete the S3 bucket and free up the bucket name, you can set openshift_aws_really_delete_s3_bucket to 'true' ('false' by default).
Diffstat (limited to 'roles')
-rw-r--r-- | roles/openshift_aws/defaults/main.yml | 5 | ||||
-rw-r--r-- | roles/openshift_aws/tasks/uninstall_s3.yml | 26 |
2 files changed, 31 insertions, 0 deletions
diff --git a/roles/openshift_aws/defaults/main.yml b/roles/openshift_aws/defaults/main.yml index c8d385db5..1696c2751 100644 --- a/roles/openshift_aws/defaults/main.yml +++ b/roles/openshift_aws/defaults/main.yml @@ -322,3 +322,8 @@ openshift_aws_masters_groups: masters,etcd,nodes # By default, don't delete things like the shared IAM instance # profile and uploaded ssh keys openshift_aws_enable_uninstall_shared_objects: False +# S3 bucket names are global by default and can take minutes/hours for the +# name to become available for re-use (assuming someone doesn't take the +# name in the meantime). Default to just emptying the contents of the S3 +# bucket if we've been asked to create the bucket during provisioning. +openshift_aws_really_delete_s3_bucket: False diff --git a/roles/openshift_aws/tasks/uninstall_s3.yml b/roles/openshift_aws/tasks/uninstall_s3.yml new file mode 100644 index 000000000..0b08cbeed --- /dev/null +++ b/roles/openshift_aws/tasks/uninstall_s3.yml @@ -0,0 +1,26 @@ +--- +- name: empty S3 bucket + block: + - name: get S3 object list + aws_s3: + bucket: "{{ openshift_aws_s3_bucket_name }}" + mode: list + region: "{{ openshift_aws_region }}" + register: s3_out + + - name: delete S3 objects + aws_s3: + bucket: "{{ openshift_aws_s3_bucket_name }}" + mode: delobj + object: "{{ item }}" + with_items: "{{ s3_out.s3_keys }}" + when: openshift_aws_create_s3 | bool + +- name: delete S3 bucket + aws_s3: + bucket: "{{ openshift_aws_s3_bucket_name }}" + mode: delete + region: "{{ openshift_aws_region }}" + when: + - openshift_aws_create_s3 | bool + - openshift_aws_really_delete_s3_bucket | bool |