2017-01-19 03:29:15 +01:00
|
|
|
{%- set key = 0 -%}
|
|
|
|
{%- set value = 1 -%}
|
2017-01-19 02:40:19 +01:00
|
|
|
{%- macro keepalived_config(data, recurse=-1) -%}
|
|
|
|
{%- set recurse = recurse + 1 -%}
|
2017-01-19 01:51:16 +01:00
|
|
|
{%- if data is none -%}
|
2017-01-19 02:40:19 +01:00
|
|
|
{{- '\n' -}}
|
|
|
|
{%- elif data is string or data is number -%}
|
|
|
|
{{- data }}{{ '\n' -}}
|
2017-01-19 01:51:16 +01:00
|
|
|
{%- elif data is mapping -%}
|
2017-01-19 02:40:19 +01:00
|
|
|
{%- if recurse > 0 -%}
|
|
|
|
{{- '{\n' -}}
|
|
|
|
{%- endif -%}
|
2017-01-19 03:29:15 +01:00
|
|
|
{%- for item in data|dictsort -%}
|
|
|
|
{{- item[key] }} {{ keepalived_config(item[value], recurse) -}}
|
2017-01-19 01:51:16 +01:00
|
|
|
{%- endfor -%}
|
2017-01-19 02:40:19 +01:00
|
|
|
{%- if recurse > 0 -%}
|
|
|
|
{{- '}\n' -}}
|
|
|
|
{%- endif -%}
|
2017-01-19 02:06:48 +01:00
|
|
|
{%- else -%}
|
2017-01-19 03:38:51 +01:00
|
|
|
{%- if recurse > 0 -%}
|
|
|
|
{{- '{\n' -}}
|
|
|
|
{%- endif -%}
|
2017-01-19 03:29:15 +01:00
|
|
|
{%- for item in data -%}
|
|
|
|
{{- keepalived_config(item) -}}
|
2017-01-19 02:06:48 +01:00
|
|
|
{%- endfor -%}
|
2017-01-19 03:38:51 +01:00
|
|
|
{%- if recurse > 0 -%}
|
|
|
|
{{- '}\n' -}}
|
|
|
|
{%- endif -%}
|
2017-01-19 01:51:16 +01:00
|
|
|
{%- endif -%}
|
|
|
|
{%- endmacro -%}
|