diff --git a/defaults/main.yml b/defaults/main.yml index 19c499c..f4c3880 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -21,5 +21,6 @@ keepalived_vrrp_script_map: {} keepalived_vrrp_scripts: {} keepalived_vrrp_track_processes: {} +keepalived_vrrp_sync_groups: {} keepalived_vrrp_instances: {} diff --git a/templates/etc/keepalived/keepalived.conf.j2 b/templates/etc/keepalived/keepalived.conf.j2 index a0e8ea6..28afe19 100644 --- a/templates/etc/keepalived/keepalived.conf.j2 +++ b/templates/etc/keepalived/keepalived.conf.j2 @@ -75,14 +75,12 @@ vrrp_track_process {{ key }} { } {% endfor %} -{% if keepalived_vrrp_sync_groups is defined %} -{% for name, sync_group in keepalived_vrrp_sync_groups.items() %} - +{% for name, sync_group in keepalived_vrrp_sync_groups.items() | sort %} vrrp_sync_group {{ name }} { group { - {% for instance in sync_group.instances -%} - {{ instance }} - {% endfor -%} +{% for instance in sync_group.instances | default([]) %} + {{ instance }} +{% endfor %} } {% if sync_group.notify_master is defined %} notify_master "{{ sync_group.notify_master }}" @@ -95,7 +93,7 @@ vrrp_sync_group {{ name }} { {% endif %} } {% endfor %} -{% endif %} + {% for key, value in keepalived_vrrp_instances.items() | sort %} vrrp_instance {{ key }} { interface {{ value.interface }} diff --git a/tests/vars/vagrant.yml b/tests/vars/vagrant.yml index 3b3a279..59e7b28 100644 --- a/tests/vars/vagrant.yml +++ b/tests/vars/vagrant.yml @@ -61,3 +61,8 @@ keepalived_vrrp_instances: # notify: "{{ keepalived_vrrp_script_map['keepalived-notify']['dest'] }}" # notify_user: root + +#keepalived_vrrp_sync_groups: +# VG_1: +# instances: +# - VI_1