role_wireguard/tasks/main.yml

51 lines
1.2 KiB
YAML
Raw Normal View History

2023-04-13 07:25:26 +00:00
---
# tasks file for wireguard
- name: Installer le paquet
ansible.builtin.apt:
update_cache: true
name: wireguard
when: wireguard_module_host | length == 0
delegate_to: "{{ wireguard_module_host }}"
2023-04-13 07:25:26 +00:00
- 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
delegate_to: "{{ wireguard_module_host }}"
when: wireguard_module_host | length > 0
become: true
- name: Installer l'outil de configuration
ansible.builtin.apt:
update_cache: true
name: wireguard-tools
when: wireguard_module_host | length > 0
- 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