On 10/09/2022 18:44, Sagan wrote:
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

Using lineinfile doesn't make sense when your write the whole file. In this 
case the template module is the better choice.

Regards

             Racke



On Saturday, September 10, 2022 at 5:47:07 PM UTC+2 ahar...@gmail.com 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 <http://192.168.1.1>:
    - node: node1
      state: up

    192.168.1.2 <http://192.168.1.2>:
    - node: nod2
       state: down

    192.168.1.3 <http://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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com
 
<https://groups.google.com/d/msgid/ansible-project/24e2bebe-0759-4512-9347-d993a0b10f87n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper

--
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/151098b0-98da-c694-4c36-f431d3b5e5ed%40linuxia.de.

Reply via email to