# Need help on how to generate a configuration file and use it to start my client

**URL:** <https://forum.ansible.com/t/need-help-on-how-to-generate-a-configuration-file-and-use-it-to-start-my-client/30178>\
**Category:** Ansible Developer\
**Created:** [April 24, 2019, 5:54pm UTC](https://forum.ansible.com/t/need-help-on-how-to-generate-a-configuration-file-and-use-it-to-start-my-client/30178 "2019-04-24T17:54:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Des\_Sindatry](https://avatars.discourse-cdn.com/v4/letter/d/94ad74/32.png) [@Des\_Sindatry](https://forum.ansible.com/u/Des_Sindatry)\
**Post date:** [April 24, 2019, 5:54pm UTC](https://forum.ansible.com/t/need-help-on-how-to-generate-a-configuration-file-and-use-it-to-start-my-client/30178/1 "2019-04-24T17:54:15Z")

</div>

Hello,

I have a configuration file which i need to generate using ansible. The key question is how to generate this file ? what module can i use ?

example:

There are close to 25 lines like this which i have to generate . How can i do it.

First option is to use “lineinfile” module which will make my playbook really big  
Second option is to write a script.

# Set the ip:port for Lenses to bind to and host1 and host2

lenses.ip = 0.0.0.0  
lenses.port = 9991  
port: [  
{id:BROKER\_ID\_1, port:9581, host:“host1”},  
{id:BROKER\_ID\_2, port:9581, host:“host2”}

```auto

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [May 1, 2019, 4:25pm UTC](https://forum.ansible.com/t/need-help-on-how-to-generate-a-configuration-file-and-use-it-to-start-my-client/30178/2 "2019-05-01T16:25:07Z")

</div>

Use the template action, it is almost always the right answer to the  
question 'how do i generate a file'.

[https://docs.ansible.com/ansible/latest/modules/template\_module.html](https://docs.ansible.com/ansible/latest/modules/template_module.html)

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [May 4, 2019, 2:20pm UTC](https://forum.ansible.com/t/need-help-on-how-to-generate-a-configuration-file-and-use-it-to-start-my-client/30178/3 "2019-05-04T14:20:01Z")

</div>

Another module that maybe useful is the ini\_file module [https://docs.ansible.com/ansible/latest/modules/ini\_file\_module.html](https://docs.ansible.com/ansible/latest/modules/ini_file_module.html) if the file you are generating is an ini style config file.

Tony Chia
