Added key array pairs.

This commit is contained in:
Jeff Baskin 2017-01-18 20:06:48 -05:00
parent ff6fc02595
commit d66a776ddb
2 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,13 @@
{%- for key, value in data.iteritems() -%}
{{ key }} {{ keepalived_config(value) }}
{%- endfor -%}
{%- else -%}
{%- elif data is string or data is number -%}
{{ data }}{{ '\n' }}
{%- else -%}
{{ '{\n' }}
{%- for value in data -%}
{{ keepalived_config(value) }}
{%- endfor -%}
{{ '}\n' }}
{%- endif -%}
{%- endmacro -%}

View File

@ -39,5 +39,10 @@ class TestKeepalivedConfiguration(unittest.TestCase):
result = 'flintstone fred\n'
self.renderTest(testdata, result)
def test_key_array_pair(self):
testdata = {'flintstone': ['fred', 'wilma', 'pebbles']}
result = 'flintstone {\nfred\nwilma\npebbles\n}\n'
self.renderTest(testdata, result)
if __name__ == '__main__':
unittest.main()