On 2/11/20 7:52 AM, Sandy Hung wrote:
> Dear all:
> 
> I have some problem I don't know I attach ebs from snapshot but attach show 
> error message please help thanks.
> 
> fatal: [localhost]: FAILED! => {
>     "msg": "The task includes an option with an undefined variable. The error 
> was: list object has no element 0\n\nThe
> error appears to be in '/home/sandy/aws/create-EBS.yml': line 74, column 6, 
> but may\nbe elsewhere in the file depending
> on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n   - 
> name: attach ebs volume from snapshot\n   
>  ^ here\n"
> 
>  - name: Get snapshot info
>      ec2_snapshot_info:
>        aws_access_key: "{{aws_access_key}}"
>        aws_secret_key: "{{aws_secret_key}}"
>        region: "{{ region }}"
>        filters:
>         "tag:Name": snapshot
>      register: ec2_snapshot_facts
> 
> 
> "this error

There are no results in the ec2_snapshot_facts.snapshots, thus retrieving the 
first element of this list
causing this error.

To see what is within ec2_snapshot_facts add a debug task:

- debug:
    msg: "{{  ec2_snapshot_facts }}"

Regards
        Racke

> 
> 
> - name: attach ebs volume from snapshot
>      ec2_vol:
>        aws_access_key: "{{ aws_access_key }}"
>        aws_secret_key: "{{ aws_secret_key }}"
>        region: "{{ region }}"
>        zone: "{{zone}}"
>        instance: "{{ instance_id }}"
>        device_name: "{{ device_name }}"
>        snapshot_ids: '{{ec2_snapshot_facts.snapshots[0].snapshot_id}}'
>        with_items: "{{instance_id}}"
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d9a813cb-04b7-4c6d-9d87-eedc8b65c8cd%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d9a813cb-04b7-4c6d-9d87-eedc8b65c8cd%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1eea8553-e33e-3a33-2da8-2961edb32873%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to