Merge pull request '[EVO] Permettre de ne pas redémarrer les services' (#2) from optionalRestart into master

Reviewed-on: #2
This commit is contained in:
pulsar89.5 2023-05-10 12:40:41 +00:00
commit f7aa5380e0
4 changed files with 53 additions and 11 deletions

View File

@ -10,6 +10,12 @@ Variable permettant de déployer le module (dkms) de wireguard sur l'hôte qui h
*<span style="text-decoration: underline">Valeur par défaut:</span> aucune*
### wireguard_restart_services
Redémarrer les services si la configuration a été modifiée.
*<span style="text-decoration: underline">Valeur par défaut:</span> `true`*
### wireguard_interfaces
Configuration des interfaces de wireguard (`/etc/wireguard/wgX.conf`).

View File

@ -2,7 +2,7 @@
# defaults file for wireguard
wireguard_module_host: ""
wireguard_listen_port: ""
wireguard_restart_services: true
wireguard_interfaces: []
# Exemple:

23
handlers/main.yml Normal file
View File

@ -0,0 +1,23 @@
---
# handlers file for wireguard
- name: Activer les services
ansible.builtin.systemd:
enabled: true
name: wg-quick@wg{{ item }}.service
become: true
loop: "{{ deploy.results | selectattr('changed', 'equalto', true) | map(attribute='index') }}"
loop_control:
index_var: index
label: wg{{ index }}
- name: Redémarrer les services
ansible.builtin.systemd:
state: restarted
name: wg-quick@wg{{ item }}.service
when: wireguard_restart_services
become: true
loop: "{{ deploy.results | selectattr('changed', 'equalto', true) | map(attribute='index') }}"
loop_control:
index_var: index
label: wg{{ index }}

View File

@ -16,14 +16,27 @@
interface: wg{{ index }}
become: true
register: deploy
notify:
- Activer les services
- Redémarrer les services
- name: Activer et redémarrer les services
ansible.builtin.systemd:
state: restarted
enabled: true
name: wg-quick@wg{{ item }}.service
become: true
loop: "{{ deploy.results | selectattr('changed', 'equalto', true) | map(attribute='index') }}"
loop_control:
index_var: index
label: wg{{ index }}
#- name: Activer les services
# ansible.builtin.systemd:
# state: restarted
# enabled: true
# name: wg-quick@wg{{ item }}.service
# become: true
# loop: "{{ deploy.results | selectattr('changed', 'equalto', true) | map(attribute='index') }}"
# loop_control:
# index_var: index
# label: wg{{ index }}
#
#- name: Redémarrer les services
# ansible.builtin.systemd:
# state: restarted
# name: wg-quick@wg{{ item }}.service
# become: true
# loop: "{{ deploy.results | selectattr('changed', 'equalto', true) | map(attribute='index') }}"
# loop_control:
# index_var: index
# label: wg{{ index }}