I have these vars:
vars:
server:
results:
name: instance_titi
type: lin
name: instance_toto
type: win
password:
stdout: Titi
rc: 0
stdout: Toto
rc: 0
And I want a variable to contain:
[
{
"name": "instance_titi",
"type": "lin",
"stdout": "Titi",
"rc": 0
}
],
[
{
"name": "instance_toto",
"type": "win",
"stdout": "Toto",
"rc": 0
}
]
I'm sure my indexes will be correctly aligned with one another, I just need to stuff one inside the other.
I get kind of close using zip:
- name: Add password for instances in server list
set_fact:
looped: "{{ server.results | zip(password) }}"
Debug gives me:
"msg": [
[
{
"name": "instance_titi",
"type": "lin"
},
{
"rc": 0,
"stdout": "Titi"
}
],
[
{
"name": "instance_toto",
"type": "win"
},
{
"rc": 0,
"stdout": "Toto"
}
]
]
Here I'm stuck.