These are drop-in modules for Ansible 2.3+ which provide the following:
- rds_cluster - can create a new RDS cluster or restore from a cluster snapshot
- rds_cluster_info - can describe RDS clusters
- rds_cluster_instance - can create a cluster instance for an existing cluster
- rds_cluster_snapshot_facts - can search and return details about RDS cluster snapshots
These modules are specifically for working with RDS Clusters.
For regular RDS instances you should look at Ansible's built-in modules.
These are provided in the event they might be of use. I will not be submitting them to the Ansible project for inclusion but you are welcome to do so.
Please read the module sources for usage information. Note that not all functionality is provided but the modules are idempotent as provided.
---
- name: Restore database snapshot
hosts: localhost
connection: local
tasks:
- name: Identify latest production cluster automated snapshot
rds_cluster_snapshot_facts:
cluster_id: "original-cluster-name"
snapshot_type: automated
status: available
sort: snapshot_create_time
sort_order: descending
sort_end: 1
tags: find-snapshot
register: snapshot
- name: Launch cluster from snapshot
rds_cluster:
cluster_id: "new-cluster-name"
snapshot_arn: "{{ snapshot.results[0].db_cluster_snapshot_arn }}"
state: present
subnet_group: "my-subnet-group"
vpc_security_group_ids:
- "my-security-group"
wait: yes
register: cluster
tags: cluster
- name: Create DB instance
rds_cluster_instance:
apply_immediately: yes
cluster_id: "{{ cluster.result.DBCluster.DBClusterIdentifier }}"
instance_id: "{{ cluster.result.DBCluster.DBClusterIdentifier }}-001"
instance_type: db.t2.small
monitoring_interval: 60
monitoring_role_arn: "my-monitoring-arn"
multi_az: no
state: present
subnet_group: "my-subnet-group"
wait: yes
register: instance
tags: instance