diff --git a/README.md b/README.md index 6a96e32..8e015c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ ## keepalived -[![Build Status](https://travis-ci.org/Oefenweb/ansible-keepalived.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-keepalived) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-keepalived-blue.svg)](https://galaxy.ansible.com/Oefenweb/keepalived) +[![Build Status](https://travis-ci.org/Oefenweb/ansible-keepalived.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-keepalived) +[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-keepalived-blue.svg)](https://galaxy.ansible.com/Oefenweb/keepalived) Set up the latest or a specific version of [Keepalived](http://www.keepalived.org/) in Debian-like systems. @@ -79,6 +80,7 @@ Set up the latest or a specific version of [Keepalived](http://www.keepalived.or * `keepalived_vrrp_instances.key.notify_master`: [optional]: Scripts that is invoked when a server changes state (to `MASTER`) * `keepalived_vrrp_instances.key.notify_master_user`: [optional]: Specify the user / group to run this script under (since `1.3.0`) * `keepalived_vrrp_instances.key.unicast_peer`: [optional]: IP address of aired unicast address (if you don't want to use multicast) + #### Dependencies None diff --git a/templates/etc/keepalived/keepalived.conf.j2 b/templates/etc/keepalived/keepalived.conf.j2 index 64a428e..e6249d7 100644 --- a/templates/etc/keepalived/keepalived.conf.j2 +++ b/templates/etc/keepalived/keepalived.conf.j2 @@ -69,14 +69,14 @@ vrrp_instance {{ key }} { {% endfor %} } -{% if value.virtual_ipaddresses_excluded | d([]) | length %} +{% if value.virtual_ipaddresses_excluded is defined %} virtual_ipaddress_excluded { -{% for virtual_ipaddress in value.virtual_ipaddresses_excluded %} +{% for virtual_ipaddress in value.virtual_ipaddresses_excluded | default([]) %} {{ virtual_ipaddress }} {% endfor %} } - {% endif %} + {% if value.nopreempt is defined and value.nopreempt | bool %} nopreempt {% endif %} @@ -89,7 +89,7 @@ vrrp_instance {{ key }} { {{ track_script }} {% endfor %} } - + {% if value.unicast_peer is defined %} unicast_peer { {{ value.unicast_peer }} diff --git a/tests/vagrant.yml b/tests/vagrant.yml index a010de7..0dc0a30 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -57,6 +57,9 @@ virtual_ipaddresses: - "10.0.0.10/24 dev {{ _keepalived_second_interface }} label {{ _keepalived_second_interface }}:1" + virtual_ipaddresses_excluded: + - "10.0.0.11/24 dev {{ _keepalived_second_interface }} label {{ _keepalived_second_interface }}:2" + - "10.0.0.12/24 dev {{ _keepalived_second_interface }} label {{ _keepalived_second_interface }}:3" track_scripts: - chk_sshd