diff --git a/keepalived/templates/config.jinja b/keepalived/templates/config.jinja index 81f3cd9..95edc30 100644 --- a/keepalived/templates/config.jinja +++ b/keepalived/templates/config.jinja @@ -1,6 +1,6 @@ {%- set key = 0 -%} {%- set value = 1 -%} -{%- set carryovers = ['vrrp_script'] -%} +{%- set carryovers = ['vrrp_instance', 'vrrp_script'] -%} {%- macro keepalived_config(data, carryover='', recurse=-1) -%} {%- set recurse = recurse + 1 -%} {%- if data is none -%} diff --git a/test/test_keepalived_config.py b/test/test_keepalived_config.py index 091e2c7..e8a916c 100755 --- a/test/test_keepalived_config.py +++ b/test/test_keepalived_config.py @@ -64,5 +64,20 @@ class TestKeepalivedConfiguration(unittest.TestCase): result = 'vrrp_script gizmo {\nbarney rubble\nfred flintstone\n}\n' self.renderTest(testdata, result) + def test_carryover_contains_arry(self): + testdata = {'vrrp_script': {'gizmo': [{'fred': 'flintstone'}, {'barney': 'rubble'}]}} + result = 'vrrp_script gizmo {\nfred flintstone\nbarney rubble\n}\n' + self.renderTest(testdata, result) + + def test_carrover_vrrp_instance(self): + testdata = {'vrrp_instance': {'gizmo': {'fred': 'flintstone', 'barney': 'rubble'}}} + result = 'vrrp_instance gizmo {\nbarney rubble\nfred flintstone\n}\n' + self.renderTest(testdata, result) + + def test_carryovers_in_an_array(self): + testdata = [{'vrrp_script': {'gizmo': {'running': 'dumdums'}}}, {'vrrp_instance': {'dumdums': {'fred': 'flintstone'}}}] + result = 'vrrp_script gizmo {\nrunning dumdums\n}\nvrrp_instance dumdums {\nfred flintstone\n}\n' + self.renderTest(testdata, result) + if __name__ == '__main__': unittest.main()