According to the ansible docs you get a single snapshot_id. snapshot_info.snapshot_id should get you the reference you need. It isn't clear from the docs whether that is a list if the EC2 has multiple EBS volumes attached.
Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jan 5, 2023, at 7:18 AM, 'Rowe, Walter P. (Fed)' via Ansible Project <[email protected]> wrote: You need to first look at the registered out snapshot_info to see what its dictionary looks like. After you snapshot the EC2, insert a debug: var=snapshot_info to see what you are being given back. With that you can to then construct a proper reference to the snapshot_id. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Jan 4, 2023, at 7:35 PM, SysAdmin EM <[email protected]> wrote: I understand, I could make it work, but not by using the ec2 snapshot module. I try to save a key as a variable but the result is empty ok: [localhost] => { "ansible_facts": { "snap_id": "" }, "changed": false } --- - name: "test" hosts: localhost gather_facts: no vars: aws_volume_id: - vol-xxxxxxxxxx tasks: - name: "create snapshot test" amazon.aws.ec2_snapshot: volume_id: "{{ item }}" wait_timeout: 900 snapshot_tags: MarkedForDeletion: true register: snapshot_info with_items: "{{ aws_volume_id }}" - set_fact: snap_id: "{{ snapshot_info | json_query('snapshot_id')}}" - name: "Debug" debug: msg: "{{ snap_id }}" This is the output changed: [localhost] => (item=vol-xxxxxxxxxxxx) => { "ansible_loop_var": "item", "changed": true, "invocation": { "module_args": { "aws_access_key": null, "aws_ca_bundle": null, "aws_config": null, "aws_secret_key": null, "debug_botocore_endpoint_logs": false, "description": null, "device_name": null, "ec2_url": null, "instance_id": null, "last_snapshot_min_age": 0, "profile": null, "region": null, "security_token": null, "snapshot_id": null, "snapshot_tags": { "MarkedForDeletion": true }, "state": "present", "validate_certs": true, "volume_id": "vol-xxxxxxxxxxx", "wait": true, "wait_timeout": 900 } }, "item": "vol-xxxxxxxxx", "snapshot_id": "snap-xxxxxxxxxxxx", What am I doing wrong? -- 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/CAGUDtnmTWBvTZGUD2RG4kSAxv6WgDM637sFFb8kkX1Aid5t5kg%40mail.gmail.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FCAGUDtnmTWBvTZGUD2RG4kSAxv6WgDM637sFFb8kkX1Aid5t5kg%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C7272a0e977cf4f14269008daef170166%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638085179327890426%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=QHTH26uKJG08637Am8NQFhVir2YwIx6W%2FaQWV2O78RA%3D&reserved=0>. -- 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/F8247068-62C6-4BC5-BBD6-812D7996E9DF%40nist.gov<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2FF8247068-62C6-4BC5-BBD6-812D7996E9DF%2540nist.gov%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C7272a0e977cf4f14269008daef170166%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638085179327890426%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=9Ro0FJKGx2xxMJbxt5hMzQmsBUPpjedgpH5KQHgUvHI%3D&reserved=0>. -- 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/AA4F4422-1FAE-45E7-9B64-92BDA1E4BBB8%40nist.gov.
