# Invalid ID from playbook

**URL:** <https://forum.ansible.com/t/invalid-id-from-playbook/35029>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [April 22, 2021, 4:31am UTC](https://forum.ansible.com/t/invalid-id-from-playbook/35029 "2021-04-22T04:31:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@Andrew\_Morgan1](https://forum.ansible.com/u/Andrew_Morgan1)\
**Post date:** [April 22, 2021, 4:31am UTC](https://forum.ansible.com/t/invalid-id-from-playbook/35029/1 "2021-04-22T04:31:31Z")

</div>

Hello All,

I have a ansible playbook that run successfully except the last step which is to delete EBS voumes from a server.

1)It launches a server  
2Gets the facts about the ec2 instances

3)kills the server and kills the volumes(not working)  
I ran the playbook in verbose mode and got the message “invalid ID”, but the volume ID actually still exists

The full traceback is:  
File “/tmp/ansible\_ec2\_vol\_payload\_qf28\_wyv/ansible\_ec2\_vol\_payload.zip/ansible/modules/cloud/amazon/ec2\_vol.py”, line 572, in main  
File “/root/.local/lib/python3.6/site-packages/boto/ec2/connection.py”, line 585, in get\_all\_instances  
max\_results=max\_results)  
File “/root/.local/lib/python3.6/site-packages/boto/ec2/connection.py”, line 681, in get\_all\_reservations  
[(‘item’, Reservation)], verb=‘POST’)  
File “/root/.local/lib/python3.6/site-packages/boto/connection.py”, line 1186, in get\_list  
raise self.ResponseError(response.status, response.reason, body)  
failed: [Investing] (item={u’status’: u’attached’, u’delete\_on\_termination’: False, u’attach\_time’: u’2021-04-22T04:06:27+00:00’, u’volume\_id’: u’vol-0fbbe014d0aaa7484’}) =\> {  
“ansible\_loop\_var”: “item”,  
“changed”: false,  
“invocation”: {  
“module\_args”: {

“item”: {  
“attach\_time”: “2021-04-22T04:06:27+00:00”,  
“delete\_on\_termination”: false,  
“status”: “attached”,  
“volume\_id”: “vol-0fbbe014d0aaa7484”  
},  
“msg”: “Invalid id: "vol-0fbbe014d0aaa7484"”

My code is below, please assist if you can I would appreciate the help.

- name: Launch instance  
ec2:  
aws\_access\_key: “{{aws\_access\_key}}”  
aws\_secret\_key: “{{aws\_secret\_key}}”  
key\_name: “{{ keypair }}”  
group: “{{ group }}”  
instance\_type: m1.small  
image: ami-0ddXXXXX2b1a

# image: “{{ ami.image\_id }}”

wait: true  
region: us-east-1  
register: ec2

- name: Add new instance to host group  
add\_host:  
hostname: “{{ ec2.instances[0].public\_ip }}”  
groupname: delegate

- name: Pausing for aws 2/2 checks passed  
pause:  
minutes: 3

- name: Waiting for SSH to come up  
delegate\_to: “{{ ec2.instances[0].public\_ip }}”  
ignore\_errors: yes  
wait\_for:  
delay: 5  
timeout: 300  
port: “{{ ansible\_ssh\_port }}”

- name: Testing out the servers  
ignore\_errors: yes  
shell: “. /etc/profile; echo $DEV\_ENV”  
args:  
executable: /bin/bash  
delegate\_to: “{{ ec2.instances[0].public\_ip }}”  
register: ENTRY

- name: Output for test server  
debug: msg=“{{ ENTRY.stdout }}”

- name: getting instance id  
delegate\_to: “{{ ec2.instances[0].public\_ip }}”  
ignore\_errors: yes  
shell: “wget -q -O - [http://169.254.169.254/latest/meta-data/instance-id](http://169.254.169.254/latest/meta-data/instance-id)”  
register: instanceterminate

- name: Get New Instance EBS drives  
ec2\_instance\_info:  
instance\_ids: “{{ instanceterminate.stdout }}”  
aws\_access\_key: “{{aws\_access\_key}}”  
aws\_secret\_key: “{{aws\_secret\_key}}”  
region: us-east-1  
register: ec2\_facts\_new

- name: Terminate instances that were previously launched  
ignore\_errors: yes  
ec2:  
aws\_access\_key: “{{aws\_access\_key}}”  
aws\_secret\_key: “{{aws\_secret\_key}}”  
state: ‘absent’  
instance\_ids: “{{ instanceterminate.stdout }}”  
region: us-east-1  
delegate\_to: ansible

- name: Pausing for volume check  
pause:  
minutes: 1

- name: Destroy all volumes  
ec2\_vol:  
aws\_access\_key: “{{aws\_access\_key}}”  
aws\_secret\_key: “{{aws\_secret\_key}}”  
instance: “{{ item.volume\_id }}”  
state: absent  
region: us-east-1  
with\_items: “{{ ec2\_facts\_new.instances[0].block\_device\_mappings | map(attribute=‘ebs’)| list }}”
