IF you have your closters has dicts in your variable you can use a loop with dict2items and loop around it, as to writing it in your file you can use this module https://docs.ansible.com/ansible/latest/collections/ansible/builtin/lineinfile_module.html
On Saturday, September 10, 2022 at 5:47:07 PM UTC+2 [email protected] wrote: > Hello All, > > I'm looking for help on below guery. As bit new to Anisble I could not > find solution thought I sent lot of time.. > > Thank you in advance. > > I have data getting through set_fact/ *json_query* using *loop* for > multiple clusters as below example. > I have saved date to *variable*: *Clusters* > > It would be like this when I read variable saved data. > > *Clusters*: > 192.168.1.1: > - node: node1 > state: up > > 192.168.1.2: > - node: nod2 > state: down > > 192.168.1.3: > -node: node3 > state: up > > and so on.... > > How do I get this date to csv file like below? > > Clusters,192.168.1.1,node1,up > Clusters,192.168.1.2,node2,down > Clusters,192.168.1.3,node3,up > -- 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/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com.
