You've already forked role_keepalived
Compare commits
6 Commits
main
...
584ebe42e5
Author | SHA1 | Date | |
---|---|---|---|
584ebe42e5 | |||
4bc5f1e12a | |||
2ae07d3c35 | |||
225a8c8021 | |||
570ceda411 | |||
434ec3ca1f |
@@ -58,12 +58,12 @@ 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
|
### keepalived_notify
|
||||||
|
|
||||||
Booléen permettant d'activer le script de notification.<br>
|
Dictionnaire comportant des booléens permettant d'activer les scripts en fonction de l'état.<br>
|
||||||
Le script est déployé dans `/etc/keepalived/notify.sh`.
|
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`*
|
*<span style="text-decoration: underline">Valeur par défaut:</span> `false` (pour chaque état)*
|
||||||
|
|
||||||
### keepalived_track_scripts
|
### keepalived_track_scripts
|
||||||
|
|
||||||
|
@@ -13,22 +13,21 @@ keepalived_ipv6: ""
|
|||||||
|
|
||||||
keepalived_peers: []
|
keepalived_peers: []
|
||||||
|
|
||||||
keepalived_notify_enable: false
|
keepalived_notify:
|
||||||
keepalived_notify_pre: {}
|
- master: false
|
||||||
keepalived_notify_is_master: {}
|
- backup: false
|
||||||
keepalived_notify_is_backup: {}
|
- fault: false
|
||||||
keepalived_notify_is_fault: {}
|
- stop: false
|
||||||
keepalived_notify_by_default: {}
|
|
||||||
|
|
||||||
keepalived_track_scripts: []
|
keepalived_track_scripts: []
|
||||||
# Example:
|
# Exemple:
|
||||||
# - name: check_haproxy_8080
|
# - name: check_haproxy_8080
|
||||||
# command: /usr/bin/nc -zv 127.0.0.1 8080
|
# command: /usr/bin/nc -zv 127.0.0.1 8080
|
||||||
# - name: check_haproxy_8081
|
# - name: check_haproxy_8081
|
||||||
# command: /usr/bin/nc -zv 127.0.0.1 8081
|
# command: /usr/bin/nc -zv 127.0.0.1 8081
|
||||||
|
|
||||||
keepalived_track_processes: []
|
keepalived_track_processes: []
|
||||||
# Example:
|
# Exemple:
|
||||||
# - name: check_haproxy
|
# - name: check_haproxy
|
||||||
# search: /usr/sbin/haproxy
|
# search: /usr/sbin/haproxy
|
||||||
# quorum: 2
|
# quorum: 2
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
# handlers file for keepalived
|
# handlers file for keepalived
|
||||||
|
|
||||||
- name: Restart keepalived.service
|
- name: Redémarrer keepalived.service
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
state: restarted
|
state: restarted
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
galaxy_info:
|
galaxy_info:
|
||||||
namespace: ykn
|
namespace: ykn
|
||||||
author: pulsar89.5
|
author: pulsar89.5
|
||||||
description: Deploy keepalived
|
description: Rôle de déploiement de keepalived
|
||||||
|
|
||||||
license: GPL-3.0-or-later
|
license: GPL-3.0-or-later
|
||||||
|
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for keepalived
|
|
||||||
|
|
||||||
- name: Deploy configuration
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: keepalived.j2
|
|
||||||
dest: /etc/keepalived/keepalived.conf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: u=rw,g=r,o=r
|
|
||||||
become: true
|
|
||||||
notify: Restart keepalived.service
|
|
||||||
|
|
||||||
- name: Deploy sudoers configuration
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: sudoers.j2
|
|
||||||
dest: /etc/sudoers.d/keepalived_script
|
|
||||||
owner: root
|
|
||||||
group: keepalived_script
|
|
||||||
mode: u=rwx,g=rx,o=
|
|
||||||
validate: /usr/sbin/visudo -cf %s
|
|
||||||
when:
|
|
||||||
- keepalived_notify_enable
|
|
||||||
- keepalived_sudoers_cmd | length > 0
|
|
||||||
become: true
|
|
||||||
notify: Restart keepalived.service
|
|
||||||
|
|
||||||
- name: Deploy notify script
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: notify.bash.j2
|
|
||||||
dest: /etc/keepalived/notify.bash
|
|
||||||
owner: root
|
|
||||||
group: keepalived_script
|
|
||||||
mode: u=rwx,g=rx,o=
|
|
||||||
when: keepalived_notify_enable
|
|
||||||
become: true
|
|
||||||
notify: Restart keepalived.service
|
|
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
# tasks file for keepalived
|
|
||||||
|
|
||||||
- name: Install keepalived
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name: keepalived
|
|
||||||
become: true
|
|
@@ -1,10 +1,37 @@
|
|||||||
---
|
---
|
||||||
# tasks file for keepalived
|
# tasks file for keepalived
|
||||||
|
|
||||||
- name: Import installation tasks
|
- name: Installer le paquet
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.apt:
|
||||||
file: installation.yml
|
name: keepalived
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Import configuration tasks
|
- name: Déployer la configuration
|
||||||
ansible.builtin.import_tasks:
|
ansible.builtin.template:
|
||||||
file: configuration.yml
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: u=rw,g=r,o=r
|
||||||
|
src: keepalived.j2
|
||||||
|
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
|
||||||
|
@@ -13,14 +13,13 @@ global_defs {
|
|||||||
smtp_connect_timeout 30
|
smtp_connect_timeout 30
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
script_user keepalived_script
|
|
||||||
enable_script_security
|
enable_script_security
|
||||||
max_auto_priority 50
|
max_auto_priority 50
|
||||||
}
|
}
|
||||||
|
|
||||||
{% for script in keepalived_track_scripts %}
|
{% for script in keepalived_track_scripts %}
|
||||||
vrrp_script {{ script.name }} {
|
vrrp_script {{ script.name }} {
|
||||||
script "{{ script.command }}"
|
script {{ script.command }}
|
||||||
interval {{ script.interval }}
|
interval {{ script.interval }}
|
||||||
}
|
}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -42,13 +41,8 @@ vrrp_instance VIP_{{ keepalived_uid }} {
|
|||||||
advert_int 1
|
advert_int 1
|
||||||
|
|
||||||
{% if keepalived_peers | length > 0 %}
|
{% if keepalived_peers | length > 0 %}
|
||||||
unicast_src_ip {{ ansible_facts[keepalived_interface]['ipv4']['address'] }}
|
|
||||||
unicast_peer {
|
unicast_peer {
|
||||||
{% for peer in keepalived_peers %}
|
{{ keepalived_peers | join('\n') | indent(width=4) }}
|
||||||
{% if peer != ansible_facts[keepalived_interface]['ipv4']['address'] %}
|
|
||||||
{{ peer }}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -64,8 +58,17 @@ vrrp_instance VIP_{{ keepalived_uid }} {
|
|||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if keepalived_notify_enable %}
|
{% if keepalived_notify_master | length > 0 %}
|
||||||
notify /etc/keepalived/notify.bash
|
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 %}
|
{% endif %}
|
||||||
|
|
||||||
{% if keepalived_track_scripts | length > 0 %}
|
{% if keepalived_track_scripts | length > 0 %}
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
TYPE=$1
|
|
||||||
NAME=$2
|
|
||||||
STATE=$3
|
|
||||||
|
|
||||||
{% if keepalived_notify_pre | length > 0 %}
|
|
||||||
{{ keepalived_notify_pre }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
# Use keepalived state
|
|
||||||
case $STATE in
|
|
||||||
{% if keepalived_notify_is_master | length > 0 %}
|
|
||||||
"MASTER")
|
|
||||||
{{ keepalived_notify_is_master | indent(4) }}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
{% endif %}
|
|
||||||
{% if keepalived_notify_is_backup | length > 0 %}
|
|
||||||
"BACKUP")
|
|
||||||
{{ keepalived_notify_is_backup | indent(4) }}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
{% endif %}
|
|
||||||
{% if keepalived_notify_is_fault | length > 0 %}
|
|
||||||
"FAULT")
|
|
||||||
{{ keepalived_notify_is_fault | indent(4) }}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
{% endif %}
|
|
||||||
{% if keepalived_notify_by_default | length > 0 %}
|
|
||||||
*)
|
|
||||||
{{ keepalived_notify_by_default | indent(4) }}
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
{% endif %}
|
|
||||||
esac
|
|
@@ -1,5 +0,0 @@
|
|||||||
# {{ ansible_managed }}
|
|
||||||
|
|
||||||
{% for cmd in keepalived_sudoers_cmd %}
|
|
||||||
keepalived_script ALL=(ALL) NOPASSWD:{{ cmd }}
|
|
||||||
{% endfor %}
|
|
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
# vars file for keepalived
|
|
||||||
|
|
||||||
users:
|
|
||||||
- name: keepalived_script
|
|
||||||
comment: "Dedicated user for keepalived script"
|
|
||||||
update_password: on_create
|
|
||||||
password_lock: true
|
|
||||||
shell: /bin/bash
|
|
Reference in New Issue
Block a user