forked from ansible-collections/amazon.aws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
s3_bucket: object lock enabled (ansible-collections#1372) (ansible-co…
…llections#1407) [PR ansible-collections#1372/8aec8f1b backport][stable-5] s3_bucket: object lock enabled SUMMARY Fixes ansible-collections#1347 ISSUE TYPE Feature Pull Request COMPONENT NAME s3_bucket ADDITIONAL INFORMATION Reviewed-by: Mark Chappell Reviewed-by: Alina Buzachis Reviewed-by: Alina Buzachis
- Loading branch information
Showing
4 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- s3_bucket - add option to support creation of buckets with object lock enabled (https://github.com/ansible-collections/amazon.aws/pull/1372). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/object_lock.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
--- | ||
- module_defaults: | ||
group/aws: | ||
aws_access_key: "{{ aws_access_key }}" | ||
aws_secret_key: "{{ aws_secret_key }}" | ||
security_token: "{{ security_token | default(omit) }}" | ||
region: "{{ aws_region }}" | ||
block: | ||
- set_fact: | ||
local_bucket_name: "{{ bucket_name | hash('md5')}}-objectlock" | ||
|
||
# ============================================================ | ||
|
||
- name: 'Create a simple bucket' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}' | ||
state: present | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
- not output.object_lock_enabled | ||
|
||
- name: 'Re-disable object lock (idempotency)' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}' | ||
state: present | ||
object_lock_enabled: false | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- not output.changed | ||
- not output.object_lock_enabled | ||
|
||
- name: 'Enable object lock' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}' | ||
state: present | ||
object_lock_enabled: true | ||
register: output | ||
ignore_errors: true | ||
|
||
- assert: | ||
that: | ||
- output is failed | ||
|
||
- name: Delete test s3 bucket | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}' | ||
state: absent | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
|
||
# ============================================================ | ||
|
||
- name: 'Create a bucket with object lock enabled' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: present | ||
object_lock_enabled: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
- output.object_lock_enabled | ||
|
||
- name: 'Disable object lock' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: present | ||
object_lock_enabled: false | ||
register: output | ||
ignore_errors: true | ||
|
||
- assert: | ||
that: | ||
- output is failed | ||
|
||
- name: 'Re-Enable object lock (idempotency)' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: present | ||
object_lock_enabled: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- not output.changed | ||
- output.object_lock_enabled | ||
|
||
- name: 'Touch bucket with object lock enabled (idempotency)' | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: present | ||
object_lock_enabled: true | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- not output.changed | ||
- output.object_lock_enabled | ||
|
||
- name: Delete test s3 bucket | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: absent | ||
register: output | ||
|
||
- assert: | ||
that: | ||
- output.changed | ||
|
||
# ============================================================ | ||
always: | ||
- name: Ensure all buckets are deleted | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}' | ||
state: absent | ||
ignore_errors: yes | ||
|
||
- name: Ensure all buckets are deleted | ||
s3_bucket: | ||
name: '{{ local_bucket_name }}-2' | ||
state: absent | ||
ignore_errors: yes |