Starting the work to add indention back in.
This commit is contained in:
parent
1ee609a616
commit
9a3410a34c
@ -2,15 +2,16 @@
|
|||||||
{%- set value = 1 -%}
|
{%- set value = 1 -%}
|
||||||
{%- set carryovers = ['real_server', 'virtual_server', 'virtual_server_group',
|
{%- set carryovers = ['real_server', 'virtual_server', 'virtual_server_group',
|
||||||
'vrrp_instance', 'vrrp_script', 'vrrp_sync_group'] -%}
|
'vrrp_instance', 'vrrp_script', 'vrrp_sync_group'] -%}
|
||||||
{%- macro keepalived_config(data, carryover='', recurse=-1) -%}
|
{%- macro keepalived_config(data, carryover='', recurse=-1, indent=0) -%}
|
||||||
{%- set recurse = recurse + 1 -%}
|
{%- set recurse = recurse + 1 -%}
|
||||||
{%- if data is none -%}
|
{%- if data is none -%}
|
||||||
{{- '\n' -}}
|
{{- '\n' -}}
|
||||||
{%- elif data is string or data is number -%}
|
{%- elif data is string or data is number -%}
|
||||||
{{- data }}{{ '\n' -}}
|
{{- data|string|indent(indent, True) }}{{ '\n' -}}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- if recurse > 0 -%}
|
{%- if recurse > 0 -%}
|
||||||
{{- '{\n' -}}
|
{{- '{\n' -}}
|
||||||
|
{%- set indent = indent + 2 -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if data is mapping -%}
|
{%- if data is mapping -%}
|
||||||
{%- for item in data|dictsort -%}
|
{%- for item in data|dictsort -%}
|
||||||
@ -20,12 +21,15 @@
|
|||||||
{%- if carryover -%}
|
{%- if carryover -%}
|
||||||
{{- carryover }}{{ ' ' -}}
|
{{- carryover }}{{ ' ' -}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{{- item[key] }} {{ keepalived_config(item[value], recurse=recurse) -}}
|
{%- if item[value] is string or item[value] is not iterable -%}
|
||||||
|
{%- set indent = 0 -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{{- item[key] }} {{ keepalived_config(item[value], recurse=recurse, indent=indent) -}}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- for item in data -%}
|
{%- for item in data -%}
|
||||||
{{- keepalived_config(item) -}}
|
{{- keepalived_config(item, indent=indent) -}}
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if recurse > 0 -%}
|
{%- if recurse > 0 -%}
|
||||||
|
@ -41,7 +41,7 @@ class TestKeepalivedConfiguration(unittest.TestCase):
|
|||||||
|
|
||||||
def test_key_array_pair(self):
|
def test_key_array_pair(self):
|
||||||
testdata = {'flintstone': ['fred', 'wilma', 'pebbles']}
|
testdata = {'flintstone': ['fred', 'wilma', 'pebbles']}
|
||||||
result = 'flintstone {\nfred\nwilma\npebbles\n}\n'
|
result = 'flintstone {\n fred\n wilma\n pebbles\n}\n'
|
||||||
self.renderTest(testdata, result)
|
self.renderTest(testdata, result)
|
||||||
|
|
||||||
def test_key_hash_pair(self):
|
def test_key_hash_pair(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user