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