Hello Mr. Botka,

This is exactly what I am looking for. It looks so neat with ini_file 
module instead of template. I'll play with it in my tasks.

Thank you very much! :)

- Xinhuan

On Thursday, January 16, 2020 at 10:50:25 AM UTC-5, Vladimir Botka wrote:
>
> On Thu, 16 Jan 2020 05:49:07 -0800 (PST) 
> Xinhuan Zheng <[email protected] <javascript:>> wrote: 
>
> >     sssd_config: 
> >       sssd: 
> >         debug_level: 1 
> >         additional_key: additional_value 
> >         another_addtional_key: another_additional_value 
> >       nss: 
> >         reconnection_retries: 3 
> >         additional_key: additional_value 
> >         another_addtional_key: another_additional_value 
> >       pam: 
> >         debug_level: 5 
> >         additional_key: additional_value 
> >         another_addtional_key: another_additional_value 
> > 
> > Because this is so difficult to manipulate in template (I spend most 
> > yesterday to figure it out), I think it is probably better just put 
> > INI-style content into template file 
>
> It also possible to use module 'ini_file' 
> https://docs.ansible.com/ansible/latest/modules/ini_file_module.html 
>
> With the configuration data transformed to this list 
>
>       sssd_config: 
>         - params: 
>             - additional_key: additional_value 
>             - reconnection_retries: 3 
>             - another_addtional_key: another_additional_value 
>           section: nss 
>         - params: 
>             - debug_level: 5 
>             - another_addtional_key: another_additional_value 
>             - additional_key: additional_value 
>           section: pam 
>         - params: 
>             - debug_level: 1 
>             - another_addtional_key: another_additional_value 
>             - additional_key: additional_value 
>           section: sssd 
>
> the task below 
>
>     - ini_file: 
>         path: /scratch/tmp/config.ini 
>         section: "{{ item.0.section }}" 
>         option: "{{ item.1.keys()|list|first }}" 
>         value: "{{ item.1.values()|list|first }}" 
>       with_subelements: 
>         - "{{ sssd_config }}" 
>         - params 
>
> gives 
>
> $ cat /scratch/tmp/config.ini 
> [nss] 
> additional_key = additional_value 
> reconnection_retries = 3 
> another_addtional_key = another_additional_value 
> [pam] 
> debug_level = 5 
> another_addtional_key = another_additional_value 
> additional_key = additional_value 
> [sssd] 
> debug_level = 1 
> another_addtional_key = another_additional_value 
> additional_key = additional_value 
>
> -- 
>

-- 
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/eeb236a9-a093-4f7c-b981-943f43989367%40googlegroups.com.

Reply via email to