On Thu, 16 Jan 2020 05:49:07 -0800 (PST) Xinhuan Zheng <[email protected]> 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/20200116164920.529c3f99%40gmail.com.
pgpIa1tyFhD1N.pgp
Description: OpenPGP digital signature
