keepalived-formula/keepalived/templates/keepalived.jinja
2016-10-23 23:12:25 -04:00

49 lines
1.5 KiB
Django/Jinja

# keepalived configuration
#
# **** DO NOT EDIT THIS FILE ****
#
# This file is managed by Salt.
# Any changes will be overwritten.
{{ '\n' }}
{%- import_yaml 'keepalived/defaults.yaml' as keepalived_defaults -%}
{%- set keepalived_final_values = salt.pillar.get(
'keepalived',
default=keepalived_defaults,
merge=True) -%}
{%- 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 and not carryover -%}
{{- " {\n" -}}
{%- endif -%}
{%- if data is mapping -%}
{%- for entry in data|dictsort -%}
{%- if entry[0] in groupings -%}
{{- config_entries(entry[1], indents, carryover=entry[0]) -}}
{%- else -%}
{%- if carryover -%}
{{ carryover|indent(indents, True) }}{{ ' ' }}
{%- endif -%}
{{ entry[0]|indent(indents, True) }}
{%- if entry[1] is defined -%}
{{- config_entries(entry[1], indents + 2) -}}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{%- for entry in data -%}
{{- config_entries(entry, indents) -}}
{%- endfor -%}
{%- endif -%}
{%- if indents != 0 and not carryover -%}
{{ '}'|indent(indents - 2, True) }}{{ '\n' }}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}
{{ config_entries(keepalived_final_values, 0) }}