On 5/11/20 2:17 PM, Sivaraman P wrote:
> Hi All,
> 
> I am using Line in file nodule to write a list output in ansible to a file in 
> the target machine.
> 
> Below is the code i have used.
> 
> hosts: localhost
> tasks:
>   - lineinfile:
>       create: yes
>       regexp: "NONEXISTENTLINE"
>       dest: /projects/testing/check.txt
>       line : "{{item}}"
>       state: present
>     with_items:
>     - "{{something}}"
> 
> And that something is a list and its value is given below,
> 
> ["WOAprofile1",
> "WOAprofile2",
> "WOAprofile3"]
> 
> When I am using the above line in file prints each value of the list in 
> separate line.
> But I need the output in the file as below,
> WOAprofile1, WOAprofile2, WOAprofile3
> 
> Note: the number of lines in the variable "something" will be differ from 
> server to server.
>  
> 
> 

Change the line module parameter as below and drop the loop (with_items)

line: "{{ something | join(', ') }}

Regards
         Racke

-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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/e33673f7-b2b9-be45-a7d3-a7c374f735e6%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to