39 lines
929 B
Plaintext
39 lines
929 B
Plaintext
|
{%- macro toml_scalar(v, seq=False) -%}
|
||
|
{% if v is string %}
|
||
|
"{{ v | quote }}"{% if seq %},{% endif %}
|
||
|
{% elif v is sameas True or v is sameas False %}
|
||
|
{{ v | bool | lower }}{% if seq %},{% endif %}
|
||
|
{% elif v is sameas None %}
|
||
|
""{% if seq %},{% endif %}
|
||
|
{% elif v is number %}
|
||
|
{{ v }}{% if seq %},{% endif %}
|
||
|
{% endif %}
|
||
|
{%- endmacro -%}
|
||
|
|
||
|
{%- macro render_section(config = {}) -%}
|
||
|
{% for k, v in config.items() | default({}) %}
|
||
|
{% if v is mapping %}
|
||
|
[{{ k }}]
|
||
|
{{ render_section(v) }}
|
||
|
{% elif v is string %}
|
||
|
{{ k }} = "{{ v | quote }}"
|
||
|
{% elif v is sameas True or v is sameas False %}
|
||
|
{{ k }} = {{ v | bool | lower }}
|
||
|
{% elif v is sameas None %}
|
||
|
{{ k }} = ""
|
||
|
{% elif v is number %}
|
||
|
{{ k }} = {{ v }}
|
||
|
{% elif v is sequence %}
|
||
|
{{ k }} = [
|
||
|
{% for i in v | default([]) %}
|
||
|
{{ toml_scalar(i, seq=True) }}
|
||
|
{% endfor %}
|
||
|
]
|
||
|
{% endif %}
|
||
|
{% endfor %}
|
||
|
{%- endmacro -%}
|
||
|
|
||
|
# {{ ansible_managed }}
|
||
|
|
||
|
{{ render_section(influxdb_config) }}
|