I've try some subelements but cannot retrieve the right data.
On Wednesday, March 16, 2022 at 10:41:58 AM UTC+1 [email protected] wrote:
> try the *subelement *filter
> Le mardi 15 mars 2022 à 16:51:19 UTC+1, Hiero-nymo a écrit :
>
>> 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/b172badc-0b9d-4d86-9437-37d07b387dddn%40googlegroups.com.