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-proje...@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