我正在尝试使用ansible从快照中创建Aurora数据库的克隆。我使用的是rds_snapshot_facts和rds_instance模块,因为rds模块不支持Aurora。这是我有的剧本(删除了区域/配置文件)。当我运行它时,它会失败
无法从DB快照还原DB实例:当调用RestoreDBInstanceFromDBSnapshot操作时发生错误(RestoreDBInstanceFromDBSnapshot):DBSnapshot未找到:快照id
是否有人成功地使用rds_instance模块恢复了这样的快照,因为它的状态是预览,我还不确定它是否正常工作。
---
- hosts: localhost
connection: local
tasks:
- name: Get rds snapshots
rds_snapshot_facts:
db_cluster_identifier: "{{rds_live_instance}}"
register: rds_snapshot
- name: Create dev db
rds_instance:
wait: yes
vpc_security_group_ids:
- "{{rds_security_group}}"
storage_encrypted: yes
publicly_accessible: no
engine: aurora-mysql
db_subnet_group_name: default
id: "dev-{{branch}}"
cluster_id: "dev-{{branch}}-cluster"
creation_source: snapshot
availability_zone: eu-west-1a
auto_minor_version_upgrade: yes
allow_major_version_upgrade: no
db_snapshot_identifier: "{{item.db_cluster_snapshot_identifier}}"
snapshot_identifier: "{{item.db_cluster_snapshot_arn}}"
with_items:
- "{{rds_snapshot.cluster_snapshots | last }}" 发布于 2019-10-04 08:52:03
在Ansible中,我使用了shell模块+ AWS从快照恢复集群
- name: Restore Aurora DB cluster from snapshot
shell: |
aws rds restore-db-cluster-from-snapshot \
--db-cluster-identifier {{ aurora_cluster_name }} \
--snapshot-identifier {{ db_cluster_snapshot_arn }} \
--db-subnet-group-name {{ subnet_group_name }} \
--engine aurora-postgresql \
--region {{ region }}创建空集群。然后使用rds_instance模块将实例添加到集群
- name: Add Aurora DB instance to cluster
rds_instance:
region: "{{ region }}"
engine: aurora-postgresql
db_instance_identifier: "{{ aurora_cluster_name }}-instance"
instance_type: db.t3.medium
cluster_id: "{{ aurora_cluster_name }}"
db_subnet_group_name: "{{ subnet_group_name }}"
wait: yes不要忘记幂等性,首先检查集群是否已经存在。
发布于 2018-12-05 08:50:07
不熟悉Ansible,但考虑到您的错误,您似乎在调用RestoreDBInstance* api,它不适用于Aurora等基于集群的引擎。您应该调用RestoreDBCluster*版本,这将为您创建一个新的集群。然后,您需要使用CreateDbInstance Api向集群添加一个实例。
我让你自己想办法用Ansible把这个连接起来。希望这能有所帮助!
https://stackoverflow.com/questions/53555414
复制相似问题