Add playbook/role to snapshot ebs volume

This commit is contained in:
Mark O'Brien 2021-01-25 13:00:16 +00:00
parent 936f36ac3b
commit 251921da91
2 changed files with 32 additions and 0 deletions

View 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

View file

@ -0,0 +1,12 @@
---
- name: Create EC2 instance
hosts: localhost
vars_files:
- "host_vars/{{initiative_name}}.yml"
roles:
- snapshot_ebs_volume