You've already forked role_keepalived
							
							[EVO] Ajouter les scripts de notifications
This commit is contained in:
		
							
								
								
									
										13
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								README.md
									
									
									
									
									
								
							@@ -58,6 +58,19 @@ 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_scripts_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Emplacement où les scripts de keepalived seront déployés.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### keepalived_notify_{master,backup,fault,stop}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Booléen permettant d'activer ou non le script en fonction de l'état de keepalived.<br>
 | 
				
			||||||
 | 
					Les scripts sont déployés dans `<keepalived_scripts_path>/notify_{master,backup,fault,stop}.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.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,13 @@ keepalived_ipv6: ""
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
keepalived_peers: []
 | 
					keepalived_peers: []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					keepalived_scripts_path: ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					keepalived_notify_master: false
 | 
				
			||||||
 | 
					keepalived_notify_backup: false
 | 
				
			||||||
 | 
					keepalived_notify_fault: false
 | 
				
			||||||
 | 
					keepalived_notify_stop: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
keepalived_track_scripts: []
 | 
					keepalived_track_scripts: []
 | 
				
			||||||
# Exemple:
 | 
					# Exemple:
 | 
				
			||||||
#  - name: check_haproxy_8080
 | 
					#  - name: check_haproxy_8080
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,31 @@
 | 
				
			|||||||
    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: 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=rX
 | 
				
			||||||
 | 
					    state: directory
 | 
				
			||||||
 | 
					  when: keepalived_scripts_path | length > 0
 | 
				
			||||||
 | 
					  become: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: Déployer les scripts
 | 
				
			||||||
 | 
					  ansible.builtin.copy:
 | 
				
			||||||
 | 
					    src: keepalived/notify_{{ item | split('_') | last }}.sh
 | 
				
			||||||
 | 
					    dest: "{{ keepalived_scripts_path }}"
 | 
				
			||||||
 | 
					    owner: keepalived_script
 | 
				
			||||||
 | 
					    group: keepalived_script
 | 
				
			||||||
 | 
					    mode: u=rx,g=rx,o=
 | 
				
			||||||
 | 
					  when:
 | 
				
			||||||
 | 
					    - keepalived_scripts_path | length > 0
 | 
				
			||||||
 | 
					    - vars[item]
 | 
				
			||||||
 | 
					  loop:
 | 
				
			||||||
 | 
					    - keepalived_notify_master
 | 
				
			||||||
 | 
					    - keepalived_notify_backup
 | 
				
			||||||
 | 
					    - keepalived_notify_fault
 | 
				
			||||||
 | 
					    - keepalived_notify_stop
 | 
				
			||||||
 | 
					  become: true
 | 
				
			||||||
 | 
					  notify: Redémarrer keepalived.service
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,6 +58,19 @@ vrrp_instance VIP_{{ keepalived_uid }} {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{% if keepalived_notify_master %}
 | 
				
			||||||
 | 
					  notify_master {{ keepalived_scripts_path }}/notify_master.sh
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					{% if keepalived_notify_backup %}
 | 
				
			||||||
 | 
					  notify_backup {{ keepalived_scripts_path }}/notify_backup.sh
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					{% if keepalived_notify_fault %}
 | 
				
			||||||
 | 
					  notify_fault {{ keepalived_scripts_path }}/notify_fault.sh
 | 
				
			||||||
 | 
					{% endif %}
 | 
				
			||||||
 | 
					{% if keepalived_notify_stop %}
 | 
				
			||||||
 | 
					  notify_stop {{ keepalived_scripts_path }}/notify_stop.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 %}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user