[EVO] Ajouter les scripts de notifications

This commit is contained in:
pulsar89.5 2023-04-21 16:32:34 +02:00
parent 954528bd4d
commit 0efc0c6887
5 changed files with 42 additions and 1 deletions

View File

@ -58,6 +58,13 @@ Passer en unicast en utilisant cette liste d'IP.
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune* *<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
### keepalived_notify_script_enabled
Booléen permettant d'activer le script de notification.<br>
Le script est déployé dans `/etc/keepalived/notify.sh`.
*<span style="text-decoration: underline">Valeur par défaut:</span> `false`*
### keepalived_track_scripts ### keepalived_track_scripts
Liste de script dont le code retour doit être à zéro pour que le membre conserve ou puisse prendre l'IP de failover. Liste de script dont le code retour doit être à zéro pour que le membre conserve ou puisse prendre l'IP de failover.

View File

@ -13,6 +13,8 @@ keepalived_ipv6: ""
keepalived_peers: [] keepalived_peers: []
keepalived_notify_script_enabled: false
keepalived_track_scripts: [] keepalived_track_scripts: []
# Exemple: # Exemple:
# - name: check_haproxy_8080 # - name: check_haproxy_8080

View File

@ -14,3 +14,10 @@ galaxy_info:
dependencies: dependencies:
- role: users - role: users
vars:
users:
- name: keepalived_script
comment: "Dedicated user for keepalived script"
update_password: on_create
password_lock: true
shell: /bin/bash

View File

@ -1,7 +1,7 @@
--- ---
# tasks file for keepalived # tasks file for keepalived
- name: Installer keepalived - name: Installer le paquet
ansible.builtin.apt: ansible.builtin.apt:
name: keepalived name: keepalived
become: true become: true
@ -15,3 +15,24 @@
dest: /etc/keepalived/keepalived.conf dest: /etc/keepalived/keepalived.conf
become: true become: true
notify: Redémarrer keepalived.service notify: Redémarrer keepalived.service
- name: Déployer les scripts
ansible.builtin.copy:
src: keepalived/notify.sh
dest: /etc/keepalived/
owner: keepalived_script
group: keepalived_script
mode: u=rx,g=rx,o=
when: keepalived_notify_script_enabled
become: true
notify: Redémarrer keepalived.service
- name: Déployer le fichier de configuration de sudoers
ansible.builtin.copy:
src: keepalived/sudoers
dest: /etc/sudoers.d/keepalived
owner: root
group: root
mode: u=rw,g=r,o=r
validate: /usr/sbin/visudo -cf %s
become: true

View File

@ -62,6 +62,10 @@ vrrp_instance VIP_{{ keepalived_uid }} {
} }
{% endif %} {% endif %}
{% if keepalived_notify_script_enabled %}
notify /etc/keepalived/notify.sh
{% endif %}
{% if keepalived_track_scripts | length > 0 %} {% if keepalived_track_scripts | length > 0 %}
track_script { track_script {
{% for script in keepalived_track_scripts %} {% for script in keepalived_track_scripts %}