Create the list. Put the below declarations into *vars*
csv_query: '[].[`Clusters`, key, value[].node, value[].state]'
csv: "{{ Clusters|dict2items|json_query(csv_query)|
map('flatten')|map('join', ',')|list }}"
gives
csv:
- Clusters,192.168.1.1,node1,up
- Clusters,192.168.1.2,node2,down
- Clusters,192.168.1.3,node3,up
Write the file
- copy:
dest: /tmp/Clusters.csv
content: "{{ csv|join('\n') }}"
gives
shell> cat /tmp/Clusters.csv
Clusters,192.168.1.1,node1,up
Clusters,192.168.1.2,node2,down
Clusters,192.168.1.3,node3,up
--
Vladimir Botka
--
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/20220910200420.1fc88026%40gmail.com.
pgpujfFm96WBf.pgp
Description: OpenPGP digital signature
