# Creating and deleting snapshots

**URL:** <https://forum.ansible.com/t/creating-and-deleting-snapshots/18049>\
**Category:** Ansible Project\
**Created:** [April 22, 2015, 11:38am UTC](https://forum.ansible.com/t/creating-and-deleting-snapshots/18049 "2015-04-22T11:38:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [April 22, 2015, 11:38am UTC](https://forum.ansible.com/t/creating-and-deleting-snapshots/18049/1 "2015-04-22T11:38:23Z")

</div>

Hi List,

I’m trying to create a playbook to create ec2 snapshots. That part woks:

> * * *
> 
> - hosts: tag\_snapshot\_yes  
> gather\_facts: true  
> tasks:
> 
> # Get a list of volume-id’s attached to the instance and put that list in
> 
> # The variable named vollist
> 
> - name: List volumes  
> ec2\_vol:  
> instance: “{{ ec2\_id }}”  
> region: “{{ ec2\_region }}”  
> state: list  
> register: vollist  
> delegate\_to: localhost

> # Simple snapshot of volume using volume\_id from the vollist variable
> 
> - name: Create snapshot  
> ec2\_snapshot:  
> region: “{{ ec2\_region }}”  
> volume\_id: “{{ item.id }}”  
> description: “snapshot of {{ item.id }} from {{ ansible\_hostname}}”  
> snapshot\_tags:  
> Name: “{{ ansible\_hostname}}”  
> with\_items: vollist.volumes  
> delegate\_to: localhost

This part works wonderfully!

But I don’t how to even start to manage the deletion of older snapshots.

Does anyone have suggestions? Or am i simply going about it the wrong way with Ansible?

Mark
