Created
July 15, 2015 07:59
-
-
Save shimizukawa/fc72a91d626a0f9e402f to your computer and use it in GitHub Desktop.
RDS instance restore from snapshot / delete instance by using ansible (1.9.1 or later)
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
[rds] | |
localhost ansible_python_interpreter=~/.venv/bin/python |
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
--- | |
- name: restore/delete rds instance | |
hosts: rds | |
connection: local | |
gather_facts: true | |
vars: | |
instance_name: 'ansibletest' | |
snapshot: 'mysql-2015-07-13' | |
tasks: | |
- name: Restore rds from snapshot | |
tags: restore | |
local_action: | |
module: rds | |
command: restore | |
snapshot: '{{ snapshot }}' | |
instance_name: '{{ instance_name }}' | |
backup_retention: 0 | |
wait: yes | |
wait_timeout: 1200 | |
- name: Delete rds instance | |
tags: delete | |
local_action: | |
module: rds | |
command: delete | |
instance_name: '{{ instance_name }}' | |
wait: yes | |
wait_timeout: 1200 |
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
$ ansible-playbook -i rds-hosts rds-manip.yml -t restore | |
$ ansible-playbook -i rds-hosts rds-manip.yml -t delete | |
$ ansible-playbook -i rds-hosts rds-manip.yml -t restore --extra-vars "snapshot=mysql-back-20150709" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment