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, default=keepalived_defaults,
merge=True) -%} 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 -%} {%- if data is string or data is number -%}
{{ data|string|indent(indents, True) }}{{ '\n' }} {{ data|string|indent(indents, True) }}{{ '\n' }}
{%- else -%} {%- else -%}
{%- if indents != 0 -%} {%- if indents != 0 and not carryover -%}
{{- "{\n" -}} {{- "{\n" -}}
{%- endif -%} {%- endif -%}
{%- if data is mapping -%} {%- if data is mapping -%}
{%- for entry in data|dictsort -%} {%- 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) }} {{ entry[0]|indent(indents, True) }}
{{- config_entries(entry[1], indents + 2) -}} {{- config_entries(entry[1], indents + 2) -}}
{%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- else -%} {%- else -%}
{%- for entry in data -%} {%- for entry in data -%}
{{- config_entries(entry, indents) -}} {{- config_entries(entry, indents) -}}
{%- endfor -%} {%- endfor -%}
{%- endif -%} {%- endif -%}
{%- if indents != 0 -%} {%- if indents != 0 and not carryover -%}
{{ '}'|indent(indents - 2, True) }}{{ '\n' }} {{ '}'|indent(indents - 2, True) }}{{ '\n' }}
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}