mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fc4bbff6e1
* Rename cloudwatchlogs_log_group_facts -> cloudwatchlogs_log_group_info. * Rename elasticache_facts -> elasticache_info. * redshift_facts -> redshift_info. * Rename route53_facts -> route53_info. * Rename rds_instance_facts -> rds_instance_info. * Rename rds_snapshot_facts -> rds_snapshot_info. * Rename iam_mfa_device_facts -> iam_mfa_device_info. * Rename iam_role_facts -> iam_role_info. * Rename iam_server_certificate_facts -> iam_server_certificate_info. * Rename elb_application_lb_facts -> elb_application_lb_info. * Renaming elb_classic_lb_facts -> elb_classic_lb_info. * elb_target_facts -> elb_target_info. * Rename elb_target_group_facts -> elb_target_group_info. * Update porting guide. * Add changelog. * Fix module defaults (both for this PR and #57613). * Two fixes.
85 lines
2.6 KiB
YAML
85 lines
2.6 KiB
YAML
---
|
|
- block:
|
|
- name: set up aws connection info
|
|
set_fact:
|
|
aws_connection_info: &aws_connection_info
|
|
aws_access_key: "{{ aws_access_key }}"
|
|
aws_secret_key: "{{ aws_secret_key }}"
|
|
security_token: "{{ security_token }}"
|
|
region: "{{ aws_region }}"
|
|
no_log: yes
|
|
|
|
- name: Ensure the resource doesn't exist
|
|
rds_instance:
|
|
id: "{{ instance_id }}"
|
|
state: absent
|
|
skip_final_snapshot: True
|
|
<<: *aws_connection_info
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- not result.changed
|
|
ignore_errors: yes
|
|
|
|
- name: Create a mariadb instance
|
|
rds_instance:
|
|
id: "{{ instance_id }}"
|
|
state: present
|
|
engine: mariadb
|
|
username: "{{ username }}"
|
|
password: "{{ password }}"
|
|
db_instance_class: "{{ db_instance_class }}"
|
|
allocated_storage: "{{ allocated_storage }}"
|
|
<<: *aws_connection_info
|
|
register: result
|
|
|
|
- name: Delete the DB instance
|
|
rds_instance:
|
|
id: "{{ instance_id }}"
|
|
state: absent
|
|
final_snapshot_identifier: "{{ instance_id }}"
|
|
<<: *aws_connection_info
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- result.changed
|
|
- "result.final_snapshot.db_instance_identifier == '{{ instance_id }}'"
|
|
|
|
- name: Check that snapshot exists
|
|
rds_snapshot_info:
|
|
db_snapshot_identifier: "{{ instance_id }}"
|
|
<<: *aws_connection_info
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- "result.snapshots | length == 1"
|
|
- "result.snapshots.0.engine == 'mariadb'"
|
|
|
|
always:
|
|
|
|
- name: Use AWS CLI to delete the snapshot
|
|
command: "aws rds delete-db-snapshot --db-snapshot-identifier '{{ instance_id }}'"
|
|
environment:
|
|
AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
|
|
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"
|
|
AWS_SESSION_TOKEN: "{{ security_token }}"
|
|
AWS_DEFAULT_REGION: "{{ aws_region }}"
|
|
|
|
# TODO: Uncomment once rds_snapshot module exists
|
|
#- name: Remove the snapshot
|
|
# rds_snapshot:
|
|
# db_snapshot_identifier: "{{ instance_id }}"
|
|
# state: absent
|
|
# <<: *aws_connection_info
|
|
# ignore_errors: yes
|
|
|
|
- name: Remove the DB instance
|
|
rds_instance:
|
|
id: "{{ instance_id }}"
|
|
state: absent
|
|
skip_final_snapshot: True
|
|
<<: *aws_connection_info
|
|
ignore_errors: yes
|