keepalived-formula/keepalived/templates/config.jinja
2017-01-18 20:40:19 -05:00

25 lines
663 B
Django/Jinja

{%- macro keepalived_config(data, recurse=-1) -%}
{%- set recurse = recurse + 1 -%}
{%- if data is none -%}
{{- '\n' -}}
{%- elif data is string or data is number -%}
{{- data }}{{ '\n' -}}
{%- elif data is mapping -%}
{%- if recurse > 0 -%}
{{- '{\n' -}}
{%- endif -%}
{%- for key, value in data.iteritems() -%}
{{- key }} {{ keepalived_config(value, recurse) -}}
{%- endfor -%}
{%- if recurse > 0 -%}
{{- '}\n' -}}
{%- endif -%}
{%- else -%}
{{- '{\n' -}}
{%- for value in data -%}
{{- keepalived_config(value) -}}
{%- endfor -%}
{{- '}\n' -}}
{%- endif -%}
{%- endmacro -%}