51 lines
1.2 KiB
YAML
51 lines
1.2 KiB
YAML
---
|
|
# tasks file for wireguard
|
|
|
|
- name: Installer le paquet
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
name: wireguard
|
|
when: wireguard_module_host | length == 0
|
|
become: true
|
|
|
|
- name: Tâches de gestion du module du noyau
|
|
block:
|
|
- name: Charger le module du noyau
|
|
community.general.modprobe:
|
|
name: wireguard
|
|
state: present
|
|
rescue:
|
|
- name: Installer le module du noyau sur l'hôte
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
name: wireguard-dkms
|
|
when: wireguard_module_host | length > 0
|
|
become: true
|
|
delegate_to: "{{ wireguard_module_host }}"
|
|
|
|
- name: Installer l'outil de configuration
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
name: wireguard-tools
|
|
when: wireguard_module_host | length > 0
|
|
become: true
|
|
|
|
- name: Déployer la configuration des interfaces
|
|
ansible.builtin.template:
|
|
src: wgN.j2
|
|
dest: /etc/wireguard/{{ interface }}.conf
|
|
owner: root
|
|
group: root
|
|
mode: u=rw,g=r,o=r
|
|
loop: "{{ wireguard_interfaces }}"
|
|
loop_control:
|
|
index_var: index
|
|
label: "{{ interface }}"
|
|
vars:
|
|
interface: wg{{ index }}
|
|
become: true
|
|
register: deploy
|
|
notify:
|
|
- Activer les services
|
|
- Redémarrer les services
|