I am very interested in this way of organizing variables for .ini files.
I wanted to use it myself, so I worked on a plugin that allows you to generate all the keys of the .ini file in one pass using the inifile module.
It works great, and I use OpenStack configuration files to manage the files.
I am not a specialist in the field of development, but I think this plugin can be useful for everyone, therefore, if someone wants to take responsibility for his support and integrate into it, he is welcome.
The plugin converts the hierarchy data into a list (section, key, value) for direct use with the inifile with_inidata module, as shown below:
vars file:
... glanceapi_conf: DEFAULT: verbose: "{{ image_log_verbose }}" rabbit_host: "{{ amqp_host }}" rabbit_port: "{{ amqp_port }}" rabbit_userid: "{{ amqp_userid }}" rabbit_password: "{{ amqp_password }}" rabbit_ha_queues: "{{ amqp_ha_queues }}" database: connection: "mysql://{{ image_db_user }}:{{ image_db_password }}@{{ db_host }}/{{ image_db }}" keystone_authtoken: auth_uri: "http://{{ identity_admin_host }}:{{ identity_api_port }}/v2.0" identity_uri: "http://{{ identity_admin_host }}:{{ identity_admin_port }}" admin_tenant_name: "{{ image_ks_tenant }}" admin_user: "{{ image_ks_user }}" admin_password: "{{ image_ks_password }}" paste_deploy: flavor: keystone glance_store: default_store: file filesystem_store_datadir: /var/lib/glance/images/ ...
plugin code:
# (c) 2014, Pierre-Yves KERVIEL < pierreyves.kerviel@orange.com >
Task Code:
- name: configuration.modify_glance-api_conf_file / modify glance-api.conf ini file ini_file: section: "{{ item.0 }}" dest: /etc/glance/glance-api.conf option: "{{ item.1 }}" value: "{{ item.2 }}" backup: yes with_inidata: glanceapi_conf
To use it, simply copy the plugin code named "dataini" into the directory defined in /etc/ansible.cfg.
It should be / usr / share / ansible _plugins / lookup_plugins for the Ubuntu distribution and write your tasks, as in my example.
I hope this plugin allows you to simplify the management of your files.