# Delete a volume and a security group not found in ansible modules

**URL:** <https://forum.ansible.com/t/delete-a-volume-and-a-security-group-not-found-in-ansible-modules/13482>\
**Category:** Ansible Project\
**Created:** [September 16, 2013, 11:28am UTC](https://forum.ansible.com/t/delete-a-volume-and-a-security-group-not-found-in-ansible-modules/13482 "2013-09-16T11:28:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cpatanaik](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@cpatanaik](https://forum.ansible.com/u/cpatanaik)\
**Post date:** [September 16, 2013, 11:28am UTC](https://forum.ansible.com/t/delete-a-volume-and-a-security-group-not-found-in-ansible-modules/13482/1 "2013-09-16T11:28:12Z")

</div>

Hi,

I have just started learning ansible. I have written a simple playbook which will create , delete a server using ansible’s ec2 module. I can also create a volume and attach it to a previously created instance.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [September 16, 2013, 11:42am UTC](https://forum.ansible.com/t/delete-a-volume-and-a-security-group-not-found-in-ansible-modules/13482/2 "2013-09-16T11:42:28Z")

</div>

The ec2 module as of version 1.3 supports a state=absent parameter which will terminate the instances (there is also an example attached to that module’s documentation here: [http://www.ansibleworks.com/docs/modules.html#ec2](http://www.ansibleworks.com/docs/modules.html#ec2)). The ec2\_vol does not yet support a state=absent parameter, so you will have to continue using manual commands to accomplish the detach/delete step. Feel free to create a github issue to request that as a feature for the ec2\_vol module.

---

<div class="post-metadata">

**Author:** ![cpatanaik](https://avatars.discourse-cdn.com/v4/letter/c/cdc98d/32.png) [@cpatanaik](https://forum.ansible.com/u/cpatanaik)\
**Post date:** [September 16, 2013, 12:07pm UTC](https://forum.ansible.com/t/delete-a-volume-and-a-security-group-not-found-in-ansible-modules/13482/3 "2013-09-16T12:07:08Z")

</div>

Thanks for the quick reply. I have another doubt. In my playbook, I have created volumes, attached it to previously created instances and registered them as ec2\_vol variable. Now if I want to detach a volume via aws cli tools, I use the following play…

- name: Detach volume from instance  
local\_action: command aws ec2 detach-volume --region=us-east-1 --volume-id={{item.id}}  
with\_items: ec2\_vol.volumes

$ stderr: A client error (InvalidVolumeID.Malformed) occurred: Invalid id: “{{item.volumeId}}” (expecting “vol-…”)

So, my question is what should be the proper format to get volume-id of newly created volumes.
