break: keepalived_vrrp_scripts variable is now a hash

This commit is contained in:
Adrien Waksberg 2021-11-05 10:05:58 +01:00
parent 5c9ee49c89
commit 8768d2fe2f
5 changed files with 13 additions and 7 deletions

View file

@ -5,6 +5,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
## [Unreleased] ## [Unreleased]
### Changed
- keepalived_vrrp_scripts variable is now a hash
### Fixed ### Fixed
- missing bracket for vrrp_sript in template - missing bracket for vrrp_sript in template

View file

@ -20,7 +20,7 @@ Install and configure Keepalived
| keepalived_smtp_server | str | no | localhost | the smtp server | | keepalived_smtp_server | str | no | localhost | the smtp server |
| keepalived_notification_mails | array | no | | the mail addresses to notify | | keepalived_notification_mails | array | no | | the mail addresses to notify |
| keepalived_vrrp_instances | array | no | | the vrrp instances | | 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 ### keepalived_vrrp_instances
@ -62,16 +62,17 @@ Example:
| Name | Type | Required | Default | Comment | | 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 | | script | str | yes | | path of the script to execute |
| interval | int | no | 2 | seconds between script invocations | | interval | int | no | 2 | seconds between script invocations |
| fall | int | no | 2 | number of successes for KO transition | | fall | int | no | 2 | number of successes for KO transition |
| rise | int | no | 2 | number of successes for OK transition | | rise | int | no | 2 | number of successes for OK transition |
| weight | int | no | 1 | weigth of script |
Example: Example:
``` ```
- name: check_nginx check_nginx:
script: /usr/local/bin/check_nginx script: /usr/local/bin/check_nginx
fall: 3 fall: 3
rise: 5 rise: 5

View file

@ -3,4 +3,4 @@ keepalived_mail_from: keepalived@test.local
keepalived_smtp_server: localhost keepalived_smtp_server: localhost
keepalived_notification_mails: [] keepalived_notification_mails: []
keepalived_vrrp_instances: [] keepalived_vrrp_instances: []
keepalived_vrrp_scripts: [] keepalived_vrrp_scripts: {}

View file

@ -5,7 +5,7 @@
- ansible-role-keepalived - ansible-role-keepalived
vars: vars:
keepalived_vrrp_scripts: keepalived_vrrp_scripts:
- name: hello hello:
script: /bin/true script: /bin/true
fall: 3 fall: 3
interval: 10 interval: 10

View file

@ -9,13 +9,14 @@ global_defs {
notification_email_from {{ keepalived_mail_from }} notification_email_from {{ keepalived_mail_from }}
smtp_server {{ keepalived_smtp_server }} 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 }}" script "{{ vrrp_script.script }}"
interval {{ vrrp_script.interval|default(2) }} interval {{ vrrp_script.interval|default(2) }}
fall {{ vrrp_script.fall|default(2) }} fall {{ vrrp_script.fall|default(2) }}
rise {{ vrrp_script.rise|default(2) }} rise {{ vrrp_script.rise|default(2) }}
weight {{ vrrp_script.weight|default(1) }}
} }
{% endfor %} {% endfor %}
{% for vrrp_instance in keepalived_vrrp_instances %} {% for vrrp_instance in keepalived_vrrp_instances %}