Invalid ID from playbook

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
    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 }}”