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

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”}


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

Another module that maybe useful is the ini_file module 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