27 lines
717 B
Django/Jinja
27 lines
717 B
Django/Jinja
{%- set key = 0 -%}
|
|
{%- set value = 1 -%}
|
|
{%- 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' -}}
|
|
{%- else -%}
|
|
{%- if recurse > 0 -%}
|
|
{{- '{\n' -}}
|
|
{%- endif -%}
|
|
{%- if data is mapping -%}
|
|
{%- for item in data|dictsort -%}
|
|
{{- item[key] }} {{ keepalived_config(item[value], recurse) -}}
|
|
{%- endfor -%}
|
|
{%- else -%}
|
|
{%- for item in data -%}
|
|
{{- keepalived_config(item) -}}
|
|
{%- endfor -%}
|
|
{%- endif -%}
|
|
{%- if recurse > 0 -%}
|
|
{{- '}\n' -}}
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endmacro -%}
|