diff --git a/keepalived/templates/config.jinja b/keepalived/templates/config.jinja index fa46d41..e02881f 100644 --- a/keepalived/templates/config.jinja +++ b/keepalived/templates/config.jinja @@ -17,10 +17,14 @@ {{- '}\n' -}} {%- endif -%} {%- else -%} - {{- '{\n' -}} + {%- if recurse > 0 -%} + {{- '{\n' -}} + {%- endif -%} {%- for item in data -%} {{- keepalived_config(item) -}} {%- endfor -%} - {{- '}\n' -}} + {%- if recurse > 0 -%} + {{- '}\n' -}} + {%- endif -%} {%- endif -%} {%- endmacro -%} diff --git a/test/test_keepalived_config.py b/test/test_keepalived_config.py index 1aed30a..30abe51 100755 --- a/test/test_keepalived_config.py +++ b/test/test_keepalived_config.py @@ -54,5 +54,10 @@ class TestKeepalivedConfiguration(unittest.TestCase): result = 'friends {\nbarney rubble\nbetty rubble\nfred flintstone\nwilma flintstone\n}\n' self.renderTest(testdata, result) + def test_ordered_hashes(self): + testdata = [{'fred': 'flintstone'}, {'wilma': 'flintstone'}, {'barney': 'rubble'}, {'betty': 'rubble'}] + result = 'fred flintstone\nwilma flintstone\nbarney rubble\nbetty rubble\n' + self.renderTest(testdata, result) + if __name__ == '__main__': unittest.main()