79 lines
1.6 KiB
YAML
79 lines
1.6 KiB
YAML
---
|
|
- hosts: wg
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Installation paquets
|
|
apt:
|
|
name: "{{ item }}"
|
|
with_items:
|
|
- wireguard
|
|
- wireguard-tools
|
|
|
|
|
|
- hosts: wg-master
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Copie du script mkwgconf-p2p.sh sur ap32-mon
|
|
copy:
|
|
src: mkwgconf-p2p.sh
|
|
dest: mkwgconf-p2p.sh
|
|
|
|
- name: Generation des fichiers de conf
|
|
shell: bash mkwgconf-p2p.sh
|
|
|
|
- name: Recuperation du fichier de conf 1
|
|
ansible.builtin.fetch:
|
|
src: wg0-1.conf
|
|
dest: wg0-1.conf
|
|
flat: yes
|
|
|
|
- name: Recuperation du fichier de conf 2
|
|
ansible.builtin.fetch:
|
|
src: wg0-2.conf
|
|
dest: wg0-2.conf
|
|
flat: yes
|
|
|
|
- name: Recuperation du fichier de conf 3
|
|
ansible.builtin.fetch:
|
|
src: wg0-3.conf
|
|
dest: wg0-3.conf
|
|
flat: yes
|
|
|
|
|
|
- hosts: wg
|
|
become: true
|
|
|
|
tasks:
|
|
- name: Copie du fichier de conf sur serveur
|
|
copy:
|
|
src: wg0-1.conf
|
|
dest: /etc/wireguard/wg0.conf
|
|
when: ansible_hostname == "ap32-mon"
|
|
|
|
|
|
- name: Copie du fichier de conf sur le client
|
|
copy:
|
|
src: wg0-2.conf
|
|
dest: /etc/wireguard/wg0.conf
|
|
when: ansible_hostname == "ap32-test"
|
|
|
|
- name: Copie du fichier de conf sur le client
|
|
copy:
|
|
src: wg0-3.conf
|
|
dest: /etc/wireguard/wg0.conf
|
|
when: ansible_hostname == "ap32-prod"
|
|
|
|
- name: Activation du service wireguard au demarrage
|
|
ansible.builtin.service:
|
|
name: wg-quick@wg0.service
|
|
enabled: true
|
|
|
|
- name: Restart du service wireguard
|
|
ansible.builtin.service:
|
|
name: wg-quick@wg0.service
|
|
state: restarted
|
|
|
|
|