Getting the special entries added.

This commit is contained in:
Jeff Baskin 2016-10-23 22:01:51 -04:00
parent 948e4eede5
commit 8fb48f7225

View File

@ -11,24 +11,30 @@
default=keepalived_defaults,
merge=True) -%}
{%- macro config_entries(data, indents) -%}
{%- set groupings = ['vrrp_script', 'vrrp_sync_group', 'vrrp_instance',
'virtual_server_group', 'virtual_server', 'real_server'] -%}
{%- macro config_entries(data, indents, carryover='') -%}
{%- if data is string or data is number -%}
{{ data|string|indent(indents, True) }}{{ '\n' }}
{%- else -%}
{%- if indents != 0 -%}
{%- if indents != 0 and not carryover -%}
{{- "{\n" -}}
{%- endif -%}
{%- if data is mapping -%}
{%- for entry in data|dictsort -%}
{%- if entry[0] in groupings -%}
{{- config_entries(entry[1], indents + 2, carryover=entry[0]) -}}
{%- else -%}
{{ entry[0]|indent(indents, True) }}
{{- config_entries(entry[1], indents + 2) -}}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for entry in data -%}
{{- config_entries(entry, indents) -}}
{%- endfor -%}
{%- endif -%}
{%- if indents != 0 -%}
{%- if indents != 0 and not carryover -%}
{{ '}'|indent(indents - 2, True) }}{{ '\n' }}
{%- endif -%}
{%- endif -%}