Created
October 17, 2018 18:31
-
-
Save metajiji/423825efa045585e52e4236db07b4d83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
gather_facts: no | |
vars: | |
config_ini: | |
section1: | |
key1: value11 | |
key2: value2 | |
section2: | |
key1: value21 | |
key2: value22 | |
tasks: | |
- name: Iterate dict | |
debug: | |
var: item | |
with_subelements: | |
- "{% set d = [] %}{% for k in config_ini %}{% set _ = d.append({'section':k, 'data': lookup('dict', config_ini[k])}) %}{% endfor %}{{d}}" | |
- data | |
- name: Set ini data | |
ini_file: | |
path: "{{ playbook_dir }}/config.ini" | |
section: "{{ item.0.section }}" | |
option: "{{ item.1.key }}" | |
value: "{{ item.1.value }}" | |
mode: 0600 | |
owner: metall | |
group: metall | |
with_subelements: | |
- "{% set d=[] %}{% for k in config_ini %}{% set _=d.append({'section':k, 'data':lookup('dict', config_ini[k])}) %}{% endfor %}{{d}}" | |
- data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment