Compare commits
No commits in common. "cf129a2a44b1e29a4bcd345f97518932228d1368" and "f7aa5380e0b3c7873f7e92bf0c85a30d5a65016e" have entirely different histories.
cf129a2a44
...
f7aa5380e0
42
tasks/configuration.yml
Normal file
42
tasks/configuration.yml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
# tasks file for wireguard
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
#- 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 }}
|
33
tasks/installation.yml
Normal file
33
tasks/installation.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
# tasks file for wireguard
|
||||||
|
|
||||||
|
- name: Installer le paquet
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
name: wireguard
|
||||||
|
when: wireguard_module_host | length == 0
|
||||||
|
become: true
|
||||||
|
register: wireguard_install
|
||||||
|
|
||||||
|
- 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
|
||||||
|
delegate_to: "{{ wireguard_module_host }}"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Installer l'outil de configuration
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
name: wireguard-tools
|
||||||
|
when: wireguard_module_host | length > 0
|
||||||
|
become: true
|
||||||
|
|
||||||
|
#- name: Créer le dossier contenant la configuration
|
||||||
|
# ansible.builtin.file:
|
||||||
|
# state: directory
|
||||||
|
# mode: u=rwx,g=,o=
|
||||||
|
# path: "{{ wireguard_conf_path }}"
|
||||||
|
# delegate_to: "{{ wireguard_server_host }}"
|
||||||
|
# become: true
|
@ -1,50 +1,8 @@
|
|||||||
---
|
---
|
||||||
# tasks file for wireguard
|
# tasks file for wireguard
|
||||||
|
|
||||||
- name: Installer le paquet
|
- name: Importer les tâches d'installation
|
||||||
ansible.builtin.apt:
|
ansible.builtin.import_tasks: installation.yml
|
||||||
update_cache: true
|
|
||||||
name: wireguard
|
|
||||||
when: wireguard_module_host | length == 0
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Tâches de gestion du module du noyau
|
- name: Importer les tâches de configuration
|
||||||
block:
|
ansible.builtin.import_tasks: configuration.yml
|
||||||
- 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
|
|
||||||
|
@ -11,9 +11,7 @@ Address = {{ item.addresses | join(', ') }}
|
|||||||
[Peer]
|
[Peer]
|
||||||
# {{ peer.name }}
|
# {{ peer.name }}
|
||||||
PublicKey = {{ peer.pubkey }}
|
PublicKey = {{ peer.pubkey }}
|
||||||
{% if peer.endpoint is defined %}
|
|
||||||
Endpoint = {{ peer.endpoint }}
|
Endpoint = {{ peer.endpoint }}
|
||||||
{% endif %}
|
|
||||||
AllowedIPs = {{ peer.allowed_ips | join(', ') }}
|
AllowedIPs = {{ peer.allowed_ips | join(', ') }}
|
||||||
{% if peer.persistent_keepalive is defined %}
|
{% if peer.persistent_keepalive is defined %}
|
||||||
PersistentKeepalive = {{ peer.persistent_keepalive }}
|
PersistentKeepalive = {{ peer.persistent_keepalive }}
|
||||||
|
Loading…
Reference in New Issue
Block a user