version finale

This commit is contained in:
Your Name
2025-12-05 15:49:05 +01:00
parent a56518aa77
commit b9a7c64819
4 changed files with 135 additions and 14 deletions

View File

@@ -1,22 +1,56 @@
---
- name:
hosts: ap33-test
- hosts: ap33-test ap33-prod
become: yes
tasks:
- name: Installer Wireguard et Wireguardtools
apt:
- wireguard
- wireguard-tools
state: present
update_cache: yes
- name: Installer WireGuard
ansible.builtin.apt:
pkg:
- wireguard
- wireguard-tools
state: present
update_cache: yes
- name: Copie fichier mkwgconfsh
- name: Copier fichier mkwgconf.sh
ansible.builtin.copy:
src: mkwgconf.sh
dest: /tmp/
when: inventory_hostname == "ap33-test"
- name: Lancement du script
ansible.builtin.shell:
cmd: bash /tmp/mkwgconf.sh
cmd: cd /tmp && bash /tmp/mkwgconf.sh
when: inventory_hostname == "ap33-test"
- name: Copier fichier wg.conf dans /etc/wireguard
ansible.builtin.copy:
src: /tmp/wg0-a.conf
dest: /etc/wireguard/wg0.conf
remote_src: yes
when: inventory_hostname == "ap33-test"
- name: Recupère fichier wg0-b.conf
ansible.builtin.fetch:
src: /tmp/wg0-b.conf
dest: wg0-b.conf
flat: yes
when: inventory_hostname == "ap33-test"
- name: Copie fichier wg0-b.conf
ansible.builtin.copy:
src: wg0-b.conf
dest: /etc/wireguard/wg0.conf
when: inventory_hostname == "ap33-prod"
- name: Lancer le service WireGuard
ansible.builtin.systemd:
name: wg-quick@wg0
state: restarted
- name: Active service wireguard
ansible.builtin.systemd:
name: wg-quick@wg0
enabled: yes