From 8768d2fe2f0f6d090b29d15b8b0cbee4e8d5d9d7 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Fri, 5 Nov 2021 10:05:58 +0100 Subject: [PATCH] break: keepalived_vrrp_scripts variable is now a hash --- CHANGELOG.md | 4 ++++ README.md | 7 ++++--- defaults/main.yml | 2 +- molecule/default/converge.yml | 2 +- templates/keepalived.conf.j2 | 5 +++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d08e72..d0cfa0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] +### Changed + +- keepalived_vrrp_scripts variable is now a hash + ### Fixed - missing bracket for vrrp_sript in template diff --git a/README.md b/README.md index 2f12816..5acaf56 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Install and configure Keepalived | keepalived_smtp_server | str | no | localhost | the smtp server | | keepalived_notification_mails | array | no | | the mail addresses to notify | | keepalived_vrrp_instances | array | no | | the vrrp instances | -| keepalived_vrrp_scripts | array | no | | the vrrp check scripts | +| keepalived_vrrp_scripts | hash | no | | the vrrp check scripts | ### keepalived_vrrp_instances @@ -62,16 +62,17 @@ Example: | Name | Type | Required | Default | Comment | |----------|-------|----------|---------|---------------------------------------| -| name | str | yes | | the script name | +| key | str | yes | | the script name | | script | str | yes | | path of the script to execute | | interval | int | no | 2 | seconds between script invocations | | fall | int | no | 2 | number of successes for KO transition | | rise | int | no | 2 | number of successes for OK transition | +| weight | int | no | 1 | weigth of script | Example: ``` -- name: check_nginx +check_nginx: script: /usr/local/bin/check_nginx fall: 3 rise: 5 diff --git a/defaults/main.yml b/defaults/main.yml index 2670d66..83ab97f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -3,4 +3,4 @@ keepalived_mail_from: keepalived@test.local keepalived_smtp_server: localhost keepalived_notification_mails: [] keepalived_vrrp_instances: [] -keepalived_vrrp_scripts: [] +keepalived_vrrp_scripts: {} diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index cab65dd..1368d9f 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -5,7 +5,7 @@ - ansible-role-keepalived vars: keepalived_vrrp_scripts: - - name: hello + hello: script: /bin/true fall: 3 interval: 10 diff --git a/templates/keepalived.conf.j2 b/templates/keepalived.conf.j2 index 2e92e41..737ea68 100644 --- a/templates/keepalived.conf.j2 +++ b/templates/keepalived.conf.j2 @@ -9,13 +9,14 @@ global_defs { notification_email_from {{ keepalived_mail_from }} smtp_server {{ keepalived_smtp_server }} } -{% for vrrp_script in keepalived_vrrp_scripts %} +{% for vrrp_script_name, vrrp_script in keepalived_vrrp_scripts.items() %} -vrrp_script {{ vrrp_script.name }} { +vrrp_script {{ vrrp_script_name }} { script "{{ vrrp_script.script }}" interval {{ vrrp_script.interval|default(2) }} fall {{ vrrp_script.fall|default(2) }} rise {{ vrrp_script.rise|default(2) }} + weight {{ vrrp_script.weight|default(1) }} } {% endfor %} {% for vrrp_instance in keepalived_vrrp_instances %}