Hello Lucie, thank you, that's perfect!
I tried all syntaxes before , that is to say
* name2.msg[item.1]
* name2.msg[item[1]]
* name2.msg.item.1
* name2.msg.item.[1]
but I nerver thought to change the dict item from [ '0', '1'] to [ 0, 1].
Now it works with the two first options....
Le 15/11/2018 à 09:32, Lucie Leistnerova a écrit :
Hello Nathanaël,
On 11/14/18 7:58 PM, Nathanaël Blanchet wrote:
> I try to get a list for all vms :
>
> "vm_name : description : id "
>
> A simple loop works:
>
> - debug:
> msg: "{{ ovirt_vms | map(attribute='snapshots') | list }}"
> register: snapshotid2
> tags: snapshots2
> - debug:
> msg: "{{ ovirt_vms | map(attribute='name') | list }}"
> register: name2
> tags: snapshots2
> - set_fact:
> toto: "{{ name2.msg[item] }} : {{
> snapshotid2.msg[0][0].description }} : {{ snapshotid2.msg[0][0].id }} "
> with_item:
> - 0
> - 1
> register: all_snapshots2
> tags: snapshots2
> - debug:
> var: all_snapshots2
> tags: snapshots2
>
>
> Now I want insert a second loop with "with_nested" like so:
>
> - set_fact:
> toto: "{{ name2.msg[item.1] }} : {{
> snapshotid2.msg[0].item.0.description }} : {{
> snapshotid2.msg[0].item.0.id }} "
> with_nested:
> - [ '0', '1']
> - [ '1', '0']
>
> but I always have this error: "The error was: 'list object' has no
> attribute u'0'"
>
> How can I do such a thing?
>
if I got it right the loop should look like this:
- set_fact:
toto: "{{ name2.msg[item.1] }} : {{
snapshotid2.msg[0][item.0].description }} : {{
snapshotid2.msg[0][item.0].id }} "
with_nested:
- [ 0, 1 ]
- [ 1, 0 ]
Best regards,
Lucie
--
Nathanaël Blanchet
Supervision réseau
Pôle Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5
Tél. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
blanchet(a)abes.fr