[EVO] Ajouter les scripts de notifications

This commit is contained in:
pulsar89.5 2023-04-21 16:32:34 +02:00
parent b002228685
commit 3b0394a7a5
4 changed files with 47 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*
### keepalived_notify
Dictionnaire comportant des booléens permettant d'activer les scripts en fonction de l'état.<br>
Les scripts sont déployés dans `/srv/keepalived/notify_{master,backup,fault,stop}.sh`.
*<span style="text-decoration: underline">Valeur par défaut:</span> `false` (pour chaque état)*
### 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.

View File

@ -13,6 +13,12 @@ keepalived_ipv6: ""
keepalived_peers: []
keepalived_notify:
- master: false
- backup: false
- fault: false
- stop: false
keepalived_track_scripts: []
# Exemple:
# - name: check_haproxy_8080

View File

@ -1,7 +1,7 @@
---
# tasks file for keepalived
- name: Installer keepalived
- name: Installer le paquet
ansible.builtin.apt:
name: keepalived
become: true
@ -15,3 +15,23 @@
dest: /etc/keepalived/keepalived.conf
become: true
notify: Redémarrer keepalived.service
- name: Créer le dossier de déploiement des scripts
ansible.builtin.file:
path: /srv/keepalived
owner: root
group: root
mode: u=rwX,g=rX,o=
state: directory
become: true
- name: Déployer les scripts
ansible.builtin.copy:
src: keepalived/notify_{{ state }}.sh
dest: /srv/keepalived/
mode: u=r,g=r,o=
loop: "{{ keepalived_notify }}"
loop_control:
index_var: state
become: true
notify: Redémarrer keepalived.service

View File

@ -58,6 +58,19 @@ vrrp_instance VIP_{{ keepalived_uid }} {
}
{% endif %}
{% if keepalived_notify_master | length > 0 %}
notify_master {{ keepalived_notify_master.dst }}
{% endif %}
{% if keepalived_notify_backup | length > 0 %}
notify_master {{ keepalived_notify_backup.dst }}
{% endif %}
{% if keepalived_notify_fault | length > 0 %}
notify_master {{ keepalived_notify_fault.dst }}
{% endif %}
{% if keepalived_notify_stop | length > 0 %}
notify_master {{ keepalived_notify_stop.dst }}
{% endif %}
{% if keepalived_track_scripts | length > 0 %}
track_script {
{% for script in keepalived_track_scripts %}