I get what you're saying, but when I just debug print {{ item }} using the results variable, I see all of the snapshots listed. If I add in the loop and use {{ item[0] }}, I see the same information, and description is included. But when I try to add description to the output, I am told that it doesn't exist. So I'm at the "until you get the expression right" phase, but no matter what I use, the expression isn't right.
- name: Gather VM Snapshot info redhat.rhv.ovirt_snapshot_info: auth: "{{ ovirt_auth }}" vm: "{{ item }}" register: result with_items: - "vm1" - name: Show results ansible.builtin.debug: msg: "{{ item[0].description }}" loop: - "{{ result.results | json_query('[*].ovirt_snapshots') }}" Thanks, Harry On Monday, February 27, 2023 at 9:22:41 AM UTC-5 Todd Lewis wrote: > Again, without the play including the "loop:" we have no idea what "item" > looks like. > > When you get something like the error you quoted, where it's looking at an > object (a list object by that message) and you don't know how to reference > data contained within, just take off all the other bits and have debug show > you > > msg: "{{ item }}" > > Then work your way one level at a time until you get the expression right. > > On Friday, February 24, 2023 at 6:20:49 PM UTC-5 lift...@gmail.com wrote: > >> I tried it 4 ways: >> msg: "{{ item.description }}" >> msg: "{{ item['description'] }}" >> msg: "{{ item[0].description }}" >> msg: "{{ item[0]['description'] }}" >> >> and all 4 give me the following error: >> >> TASK [Show results] >> *********************************************************************************************************************************************************************************** >> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with >> an undefined variable. The error was: 'list object' has no attribute >> 'description'. 'list object' has no attribute 'description'\n\nThe error >> appears to be in '/root/vm_snapshot_info.yml': line 48, column 7, but >> may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe >> offending line appears to be:\n\n\n - name: Show results\n ^ >> here\n"} >> >> Thanks, >> Harry >> On Friday, February 24, 2023 at 7:17:56 AM UTC-5 Todd Lewis wrote: >> >>> That was close, but you used a comma instead of a period in "{{ >>> item.description }}". >>> >>> -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/faaf85a9-f233-44c2-ab87-5902fcd61b07n%40googlegroups.com.