Add playbook/role to snapshot ebs volume
This commit is contained in:
parent
936f36ac3b
commit
251921da91
2 changed files with 32 additions and 0 deletions
20
ansible/roles/snapshot_ebs_volume/tasks/main.yml
Normal file
20
ansible/roles/snapshot_ebs_volume/tasks/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
|
||||
- name: Get volume id
|
||||
ec2_instance_info:
|
||||
region: "{{ aws_region }}"
|
||||
filters:
|
||||
"tag:Name": "{{ instance_name }}"
|
||||
register: instance_info
|
||||
|
||||
|
||||
- name: Display volume-id for snap
|
||||
debug: msg="{{instance_info.instances[0].block_device_mappings[0].ebs.volume_id}}"
|
||||
|
||||
|
||||
- name: create snapshot
|
||||
ec2_snapshot:
|
||||
volume_id: "{{instance_info.instances[0].block_device_mappings[0].ebs.volume_id}}"
|
||||
description: "Snapshot of volume for the {{instance_name}} ec2 instance"
|
||||
region: "{{ aws_region }}"
|
||||
wait: no
|
12
ansible/snapshot_ebs_volume.yml
Normal file
12
ansible/snapshot_ebs_volume.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
|
||||
- name: Create EC2 instance
|
||||
hosts: localhost
|
||||
|
||||
vars_files:
|
||||
- "host_vars/{{initiative_name}}.yml"
|
||||
|
||||
roles:
|
||||
- snapshot_ebs_volume
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue