keepalived-formula/keepalived/templates/config.jinja

25 lines
663 B
Plaintext
Raw Normal View History

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 01:51:16 +01:00
{%- for key, value in data.iteritems() -%}
2017-01-19 02:40:19 +01:00
{{- key }} {{ keepalived_config(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 02:40:19 +01:00
{{- '{\n' -}}
2017-01-19 02:06:48 +01:00
{%- for value in data -%}
2017-01-19 02:40:19 +01:00
{{- keepalived_config(value) -}}
2017-01-19 02:06:48 +01:00
{%- endfor -%}
2017-01-19 02:40:19 +01:00
{{- '}\n' -}}
2017-01-19 01:51:16 +01:00
{%- endif -%}
{%- endmacro -%}