Hi Team,
My playbook role receive a dict coming from a lookup file, *linux_file_list*
is the variable name of this lookup. This dict has only one key and some
lists as value. Elements of these lists are dict too.
Here's my debug to see the content:
- Name: debugging
debug:
msg:"{{ linux_file_list | dict2items }}"
And here's the result (a part...):
TASK [reposync : debugging]
*******************************************************************************************************************************************************
ok: [] => {
"msg": [
[
{
"key": "list_of_linux",
"value": [
{
"description": "linux SLES",
"enabled": 1,
"version": 15,
"name": "sles"
},
{
"description": "linux RHEL",
"enabled": 1,
"version": 8.4,
"name": "rhel"
}
]
}
]
]
}
Now, I want to define the name value as a dict to loop on this to have at
the end a loop to retrieve these variables, like so…
"name: {{ item['name'] }}"
"description: {{ item['description'] }}"
"version: {{ item['version'] }}"
etc…
Unfortunately I don't find how can i do that. I've try many things, like
item.value[0][0]
to have the first element of the first list but it doesn't run.
With set_fact i cannot do a dict on the list too:
- set_fact:
dict: “{{ dict(_keys|zip(linux_file_list)) }}"
vars:
_keys: "{{ item['value']|map(attribute='name')|list }}"
loop: "{{ linux_file_list | dict2items }}"
As anyone an Idea how can I resolve this? I can't see my problem clearly
anymore and I need your help
Thanks in advance for your help, H
--
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/8c895f08-2c3d-48c2-b1b1-0f74b8a60984n%40googlegroups.com.