-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
309 additions
and
1 deletion.
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
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ encryption_sse | |
public_access | ||
acl | ||
object_lock | ||
inventory | ||
|
||
[all:vars] | ||
ansible_connection=local | ||
|
129 changes: 129 additions & 0 deletions
129
tests/integration/targets/s3_bucket/roles/s3_bucket/tasks/inventory.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,129 @@ | ||
--- | ||
- module_defaults: | ||
group/aws: | ||
access_key: "{{ aws_access_key }}" | ||
secret_key: "{{ aws_secret_key }}" | ||
session_token: "{{ security_token | default(omit) }}" | ||
region: "{{ aws_region }}" | ||
block: | ||
- ansible.builtin.set_fact: | ||
local_bucket_name: "{{ bucket_name | hash('md5')}}-inventory-source" | ||
local_dest_bucket_name: "{{ bucket_name | hash('md5')}}-inventory-target" | ||
# ============================================================ | ||
- name: Create a simple bucket to be inventory destination | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_dest_bucket_name }}" | ||
state: present | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
|
||
- name: Create a simple bucket with minimal inventory configuration | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
inventory: | ||
id: "{{ local_dest_bucket_name }}" | ||
destination: | ||
bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- output.bucket_inventory | ||
|
||
- name: Re-configure inventory configuration | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
inventory: | ||
id: "{{ local_dest_bucket_name }}" | ||
destination: | ||
bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" | ||
schedule: "Daily" | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
- output.bucket_inventory | ||
|
||
- name: Re-configure inventory configuration (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
inventory: | ||
id: "{{ local_dest_bucket_name }}" | ||
destination: | ||
bucket: "arn:aws:s3:::{{ local_dest_bucket_name }}" | ||
schedule: "Daily" | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output is not changed | ||
- output.bucket_inventory | ||
|
||
|
||
- name: Delete inventory configuration | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output is changed | ||
- not output.bucket_inventory|bool | ||
|
||
- name: Delete inventory configuration (idempotency) | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: present | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output is not changed | ||
- not output.bucket_inventory|bool | ||
|
||
# ============================================================ | ||
|
||
- name: Delete testing s3 bucket | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: absent | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
|
||
|
||
- name: Delete testing inventory s3 bucket | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_dest_bucket_name }}" | ||
state: absent | ||
register: output | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- output.changed | ||
|
||
|
||
# ============================================================ | ||
always: | ||
- name: Ensure all buckets are deleted | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_bucket_name }}" | ||
state: absent | ||
ignore_errors: true | ||
|
||
- name: Ensure all buckets are deleted | ||
amazon.aws.s3_bucket: | ||
name: "{{ local_dest_bucket_name }}" | ||
state: absent | ||
ignore_errors: true |