# aws ece dettach Volume error

**URL:** <https://forum.ansible.com/t/aws-ece-dettach-volume-error/32171>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 7, 2020, 7:13am UTC](https://forum.ansible.com/t/aws-ece-dettach-volume-error/32171 "2020-02-07T07:13:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy.hung](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sandy.hung](https://forum.ansible.com/u/sandy.hung)\
**Post date:** [February 7, 2020, 7:13am UTC](https://forum.ansible.com/t/aws-ece-dettach-volume-error/32171/1 "2020-02-07T07:13:47Z")

</div>

dear all:

please help me how to detach volume

- name: Detach a Volume  
ec2\_vol:  
id: vol-0a75b01a93b9e6778  
region: “{{ region }}”  
instance: None

PLAY [localhost] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Create Snapshot EC2] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [localhost]

TASK [Create a Volume] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[WARNING]: The value 1000 (type int) in a string field was converted to u’1000’ (type string). If this does not look  
like what you expect, quote the entire value to ensure it does not change.

changed: [localhost]

TASK [Detach a Volume] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: `IncorrectState`Unable to detach root volume ‘vol-0a75b01a93b9e6778’ from instance ‘i-065d2c70867a8f874’3dbf5aee-9647-44de-8820-e8d6db1331d7  
fatal: [localhost]: FAILED! =\> {“changed”: false, “module\_stderr”: “Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1581059554.97-79519864016870/AnsiballZ\_ec2\_vol.py", line 102, in \n \_ansiballz\_main()\n File "/root/.ansible/tmp/ansible-tmp-1581059554.97-79519864016870/AnsiballZ\_ec2\_vol.py", line 94, in \_ansiballz\_main\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\n File "/root/.ansible/tmp/ansible-tmp-1581059554.97-79519864016870/AnsiballZ\_ec2\_vol.py", line 40, in invoke\_module\n runpy.run\_module(mod\_name=‘ansible.modules.cloud.amazon.ec2\_vol’, init\_globals=None, run\_name=‘ **main** ’, alter\_sys=True)\n File "/usr/lib/python2.7/runpy.py", line 188, in run\_module\n fname, loader, pkg\_name)\n File "/usr/lib/python2.7/runpy.py", line 82, in \_run\_module\_code\n mod\_name, mod\_fname, mod\_loader, pkg\_name)\n File "/usr/lib/python2.7/runpy.py", line 72, in \_run\_code\n exec code in run\_globals\n File "/tmp/ansible\_ec2\_vol\_payload\_ULdCkg/ansible\_ec2\_vol\_payload.zip/ansible/modules/cloud/amazon/ec2\_vol.py", line 619, in \n File "/tmp/ansible\_ec2\_vol\_payload\_ULdCkg/ansible\_ec2\_vol\_payload.zip/ansible/modules/cloud/amazon/ec2\_vol.py", line 597, in main\n File "/tmp/ansible\_ec2\_vol\_payload\_ULdCkg/ansible\_ec2\_vol\_payload.zip/ansible/modules/cloud/amazon/ec2\_vol.py", line 446, in detach\_volume\n File "/usr/local/lib/python2.7/dist-packages/boto/ec2/volume.py", line 187, in detach\n dry\_run=dry\_run\n File "/usr/local/lib/python2.7/dist-packages/boto/ec2/connection.py", line 2420, in detach\_volume\n return self.get\_status(‘DetachVolume’, params, verb=‘POST’)\n File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 1227, in get\_status\n raise self.ResponseError(response.status, response.reason, body)\nboto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request\n\<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\n`IncorrectState`Unable to detach root volume ‘vol-0a75b01a93b9e6778’ from instance ‘i-065d2c70867a8f874’3dbf5aee-9647-44de-8820-e8d6db1331d7\n”, “module\_stdout”: “”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
localhost : ok=2 changed=2 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 7, 2020, 9:58am UTC](https://forum.ansible.com/t/aws-ece-dettach-volume-error/32171/2 "2020-02-07T09:58:52Z")

</div>

The error says:  
Unable to detach root volume 'vol-0a75b01a93b9e6778' from instance  
'i-065d2c70867a8f874'

Which makes sense.

Checking on [https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html:](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-detaching-volume.html:)

"If an EBS volume is the root device of an instance, you must stop the  
instance before you can detach the volume."

So, try stopping the instance first?
