{# Copyright (C) 2020 Pedro Luis Lopez <pedroluis.lopezsanchez@gmail.com>
 # Copyright (C) 2020 Innobyte Bechea Leonardo <https://www.innobyte.com/>
 # Copyright (C) 2020 Innobyte Alin Alexandru <https://www.innobyte.com/>
 # Copyright (C) 2020 DebOps <https://debops.org/>
 # SPDX-License-Identifier: GPL-3.0-or-later
 #}
# {{ ansible_managed }}
{% for element in influxdb_server__combined_configuration | parse_kv_items %}
{%   if element.name|d() and element.state|d('present') not in [ 'absent', 'ignore' ] %}

{%     if element.name in [ 'graphite', 'collectd', 'opentsdb', 'udp' ] %}
{{ '[[{}]]'.format(element.name) }}
{%     else %}
{{ '[{}]'.format(element.name) }}
{%     endif %}
{%     if element.options|d() %}
{%       for thing in element.options %}
{%         if thing.name|d() and thing.value|d() and thing.state|d('present') != 'absent' %}
{{ '  {} = {}'.format(thing.name, thing.value) }}
{%         endif %}
{%       endfor %}
{%     endif %}
{%   endif %}
{% endfor %}
