Compare commits
10 Commits
v0.0.5c-rr
...
main
Author | SHA1 | Date | |
---|---|---|---|
b81cbb8021 | |||
065f454f6f | |||
|
d29ce732af | ||
77c6e532b3 | |||
ea95044a7d | |||
|
3cc5c7a773 | ||
|
149e630c47 | ||
2f4941c25e | |||
d6e080d014 | |||
006a4c5f4f |
12
README.md
12
README.md
@ -1,6 +1,9 @@
|
||||
# Projet SDIS29 - 2025 - Groupe 3
|
||||
**Lastest Update** Version v0.0.5c-rr : le 14/11/24 à 10h40 par Rotsy Rahaingo
|
||||
|
||||
**Lastest Update** Version v0.0.4c-jp : le 08/11/2024 à 11h10 par Jarod PAUCHET
|
||||
**Oldest Update** Version v0.0.5b-rr : le 14/11/24 à 09h35 par Rotsy Rahaingo
|
||||
|
||||
**Oldest Update** Version v0.0.4c-jp : le 08/11/2024 à 11h10 par Jarod PAUCHET
|
||||
|
||||
**Oldest Update** Version v0.0.4a-rr : le 08/11/2024 à 10h30 par Rotsy Rahaingo
|
||||
|
||||
@ -192,3 +195,10 @@ sudo sed -i "$rpl" /etc/systemd/journal-upload.conf
|
||||
sudo systemctl enable --now systemd-journal-upload.service
|
||||
sudo systemctl restart systemd-journal-upload.service
|
||||
````
|
||||
|
||||
## **Etape 6: Automatisation avec ansible**
|
||||
Il est également possible d'installer les serveurs ap33-prod et ap33-test automatiquement grâce à ansible. Comme ces machines sont en production, il sera plus judicieux de le faire sur une machine test. Il faudra donc créer deux autres machines :
|
||||
* **ap33-ans** qui contiendra les différents playbooks
|
||||
* **ap33-pt** sera la machine cible et également la machine test
|
||||
|
||||
Pour avoir plus de détails sur chaque playbook, on peut voir dans le répertoire [ansible](https://gitea.lyc-lecastel.fr/uap33-2025-r/sdis29-3/src/branch/main/ansible).
|
||||
|
@ -7,10 +7,7 @@ Ce playbook permet de faire la configuration de base :
|
||||
* installation des paquets nécessaires pour la réalisation du projet (tomcat, ant, mariadb-server)
|
||||
* installation du paquet qemu-guest-agent
|
||||
|
||||
Pour l'exécuter :
|
||||
````
|
||||
ansible-playbook -i hosts apbase.yml
|
||||
````
|
||||
Pour l'exécuter : ````ansible-playbook -i hosts apbase.yml````
|
||||
|
||||
### Playbook : apdb.yml
|
||||
Ce playbook permet de :
|
||||
@ -21,17 +18,11 @@ Ce playbook permet de :
|
||||
* importer le fichier sdis29.sql sur la base de données
|
||||
**NB**: Le module **login_unix_socket: /run/mysqld/mysqld.sock** est nécessaire à chaque fois qu'on fait appel à la base de données
|
||||
|
||||
Pour l'exécuter :
|
||||
````
|
||||
ansible-playbook - i hosts apdb.yml
|
||||
````
|
||||
Pour l'exécuter :````ansible-playbook - i hosts apdb.yml````
|
||||
|
||||
### Playbook : apdbdump.yml
|
||||
Ce playbook permet de faire une sauvegarde de la base de données :
|
||||
* export de la base de données
|
||||
* recupération du fichier dump
|
||||
|
||||
Pour l'exécuter :
|
||||
````
|
||||
ansible-playbook -i hosts apdbdump.yml
|
||||
````
|
||||
Pour l'exécuter : ````ansible-playbook -i hosts apdbdump.yml````
|
||||
|
@ -1,2 +0,0 @@
|
||||
[pt]
|
||||
ap33-pt
|
65
ansible/wg.yml
Normal file
65
ansible/wg.yml
Normal file
@ -0,0 +1,65 @@
|
||||
---
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: arrete unattended-upgrades
|
||||
service:
|
||||
name: unattended-upgrades
|
||||
state: stopped
|
||||
|
||||
- name: installe Wireguard
|
||||
apt:
|
||||
name:
|
||||
- wireguard
|
||||
- wireguard-tools
|
||||
state: present
|
||||
|
||||
- hosts: wg_master
|
||||
tasks:
|
||||
- name: copie le fichier wg0-1.conf et wg0-2.conf vers les machines master et cli
|
||||
copy:
|
||||
src: mkwgconf.sh
|
||||
dest: mkwgconf.sh
|
||||
|
||||
- name: generations fichier configuration wireguard wg0-1.conf etc
|
||||
shell: bash mkwgconf.sh
|
||||
|
||||
- name: récupération du fichier wg0-1.conf vers ap33-ans
|
||||
fetch:
|
||||
src: wg0-1.conf
|
||||
dest: wg0-1.conf
|
||||
flat: yes
|
||||
|
||||
- name: récupération du fichier wg0-2.conf vers ap33-ans
|
||||
fetch:
|
||||
src: wg0-2.conf
|
||||
dest: wg0-2.conf
|
||||
flat: yes
|
||||
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: copie fichier wg0-1 vers les clients
|
||||
copy:
|
||||
src: wg0-1.conf
|
||||
dest: /etc/wireguard/wg0.conf
|
||||
when: ansible_hostname == "ap33-mon"
|
||||
|
||||
- name: copie fichier wg0-2 vers les clients
|
||||
copy:
|
||||
src: wg0-2.conf
|
||||
dest: /etc/wireguard/wg0.conf
|
||||
when: ansible_hostname == "ap33-prod"
|
||||
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Activation de wireguard
|
||||
service:
|
||||
name: wg-quick@wg0.service
|
||||
enabled: yes
|
||||
|
||||
- name: Redémarre le wireguard
|
||||
service:
|
||||
name: wg-quick@wg0.service
|
||||
state: restarted
|
11
ansible/wireguard/hosts
Normal file
11
ansible/wireguard/hosts
Normal file
@ -0,0 +1,11 @@
|
||||
[wg]
|
||||
ap33-prod
|
||||
ap33-test
|
||||
ap33-mon
|
||||
|
||||
[wg_master]
|
||||
ap33-mon
|
||||
|
||||
[wg_cli]
|
||||
ap33-test
|
||||
ap33-prod
|
82
ansible/wireguard/mkwgconf.sh
Normal file
82
ansible/wireguard/mkwgconf.sh
Normal file
@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
|
||||
AddressAwg=10.0.0.1/24 # Adresse VPN Wireguard extremite A
|
||||
EndpointA=172.16.0.122 # Adresse extremite A
|
||||
PortA=51820 # Port ecoute extremite A
|
||||
AddressBwg=10.0.0.2/24 # Adresse VPN Wireguard extremite B
|
||||
<<<<<<< HEAD:ansible/wireguard/mkwgconf.sh
|
||||
EndpointB=172.16.0.120 # Adresse extremite B
|
||||
=======
|
||||
EndpointB=172.16.0.121 # Adresse extremite B
|
||||
>>>>>>> d29ce732af0fce68c555df54563113473c3a0c5b:ansible/mkwgconf.sh
|
||||
PortB=51820 # Port ecoute extremite B
|
||||
AddressCwg=10.0.0.3/24 # Adresse VPN Wireguard extremite C
|
||||
EndpointC=172.16.0.121 # Adresse extremite C
|
||||
PortC=51820 # Port ecoute extremite C
|
||||
|
||||
umask 077 ;
|
||||
wg genkey > endpoint-a.key
|
||||
wg pubkey < endpoint-a.key > endpoint-a.pub
|
||||
|
||||
wg genkey > endpoint-b.key
|
||||
wg pubkey < endpoint-b.key > endpoint-b.pub
|
||||
|
||||
wg genkey > endpoint-c.key
|
||||
wg pubkey < endpoint-c.key > endpoint-c.pub
|
||||
|
||||
PKA=$(cat endpoint-a.key)
|
||||
pKA=$(cat endpoint-a.pub)
|
||||
PKB=$(cat endpoint-b.key)
|
||||
pKB=$(cat endpoint-b.pub)
|
||||
PKC=$(cat endpoint-c.key)
|
||||
pKC=$(cat endpoint-c.pub)
|
||||
|
||||
cat <<FINI > wg0-1.conf
|
||||
# local settings for Endpoint A
|
||||
[Interface]
|
||||
PrivateKey = $PKA
|
||||
Address = $AddressAwg
|
||||
ListenPort = $PortA
|
||||
|
||||
# remote settings for Endpoint B
|
||||
[Peer]
|
||||
PublicKey = $pKB
|
||||
Endpoint = ${EndpointB}:$PortB
|
||||
AllowedIPs = $AddressBwg
|
||||
|
||||
# remote settings for Endpoint C
|
||||
[Peer]
|
||||
PublicKey = $pKC
|
||||
Endpoint = ${EndpointC}:$PortC
|
||||
AllowedIPs = $AddressCwg
|
||||
FINI
|
||||
|
||||
cat <<FINI > wg0-2.conf
|
||||
# local settings for Endpoint B
|
||||
[Interface]
|
||||
PrivateKey = $PKB
|
||||
Address = $AddressBwg
|
||||
ListenPort = $PortB
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = $pKA
|
||||
Endpoint = ${EndpointA}:$PortA
|
||||
AllowedIPs = $AddressAwg
|
||||
FINI
|
||||
|
||||
cat <<FINI > wg0-3.conf
|
||||
#local settings for Endpoint C
|
||||
[Interface]
|
||||
PrivateKey = $PKC
|
||||
Address = $AddressCwg
|
||||
ListenPort = $PortC
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = $pKA
|
||||
Endpoint = ${EndpointA}:$PortA
|
||||
AllowedIPs = $AddressAwg
|
||||
FINI
|
77
ansible/wireguard/wg.yml
Normal file
77
ansible/wireguard/wg.yml
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: arrete unattended-upgrades
|
||||
service:
|
||||
name: unattended-upgrades
|
||||
state: stopped
|
||||
|
||||
- name: installe Wireguard
|
||||
apt:
|
||||
name:
|
||||
- wireguard
|
||||
- wireguard-tools
|
||||
state: present
|
||||
|
||||
- hosts: wg_master
|
||||
tasks:
|
||||
- name: copie le fichier wg0-1.conf, wg0-2.conf et wg0-3.conf vers les machines master et cli
|
||||
copy:
|
||||
src: mkwgconf.sh
|
||||
dest: mkwgconf.sh
|
||||
|
||||
- name: generations fichier configuration wireguard wg0-1.conf etc
|
||||
shell: bash mkwgconf.sh
|
||||
|
||||
- name: récupération du fichier wg0-1.conf vers ap33-ans
|
||||
fetch:
|
||||
src: wg0-1.conf
|
||||
dest: wg0-1.conf
|
||||
flat: yes
|
||||
|
||||
- name: récupération du fichier wg0-2.conf vers ap33-ans
|
||||
fetch:
|
||||
src: wg0-2.conf
|
||||
dest: wg0-2.conf
|
||||
flat: yes
|
||||
|
||||
- name: récupération du fichier wg0-3.conf vers ap33-ans
|
||||
fetch:
|
||||
src: wg0-3.conf
|
||||
dest: wg0-3.conf
|
||||
flat: yes
|
||||
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: copie fichier wg0-1 vers les clients
|
||||
copy:
|
||||
src: wg0-1.conf
|
||||
dest: /etc/wireguard/wg0.conf
|
||||
when: ansible_hostname == "ap33-mon"
|
||||
|
||||
- name: copie fichier wg0-2 vers les clients
|
||||
copy:
|
||||
src: wg0-2.conf
|
||||
dest: /etc/wireguard/wg0.conf
|
||||
when: ansible_hostname == "ap33-prod"
|
||||
|
||||
- name: copie fichier wg0-3.conf vers les clients
|
||||
copy:
|
||||
src: wg0-3.conf
|
||||
dest: /etc/wireguard/wg0.conf
|
||||
when: ansible_hostname == "ap33-test"
|
||||
|
||||
- hosts: wg
|
||||
become: yes
|
||||
tasks:
|
||||
- name: Activation de wireguard
|
||||
service:
|
||||
name: wg-quick@wg0.service
|
||||
enabled: yes
|
||||
|
||||
- name: Redémarre le wireguard
|
||||
service:
|
||||
name: wg-quick@wg0.service
|
||||
state: restarted
|
17
ansible/wireguard/wg0-1.conf
Normal file
17
ansible/wireguard/wg0-1.conf
Normal file
@ -0,0 +1,17 @@
|
||||
# local settings for Endpoint A
|
||||
[Interface]
|
||||
PrivateKey = CNafmAzvjGGAFA5RsDCHtypTh9RGnAxpkxZCt9cBkXo=
|
||||
Address = 10.0.0.1/24
|
||||
ListenPort = 51820
|
||||
|
||||
# remote settings for Endpoint B
|
||||
[Peer]
|
||||
PublicKey = UMlB4+d/SYufqAGbuHDvGvkOhGKEihIgR+rhFzk3Aj0=
|
||||
Endpoint = 172.16.0.120:51820
|
||||
AllowedIPs = 10.0.0.2/24
|
||||
|
||||
# remote settings for Endpoint C
|
||||
[Peer]
|
||||
PublicKey = EWOjtZLwhNLDokDWJCONaBtqpGbr+x5tzNFeUI0hHEE=
|
||||
Endpoint = 172.16.0.121:51820
|
||||
AllowedIPs = 10.0.0.3/24
|
11
ansible/wireguard/wg0-2.conf
Normal file
11
ansible/wireguard/wg0-2.conf
Normal file
@ -0,0 +1,11 @@
|
||||
# local settings for Endpoint B
|
||||
[Interface]
|
||||
PrivateKey = SLBteS7RJPIZ0TlZ5b9D6xtHF/5VzuQGmqnzW0Kkb0g=
|
||||
Address = 10.0.0.2/24
|
||||
ListenPort = 51820
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = Fqd4WMaBpI7DAK6p2BaNhaE9VYzMRmfLxaO9uOmWTys=
|
||||
Endpoint = 172.16.0.122:51820
|
||||
AllowedIPs = 10.0.0.1/24
|
11
ansible/wireguard/wg0-3.conf
Normal file
11
ansible/wireguard/wg0-3.conf
Normal file
@ -0,0 +1,11 @@
|
||||
#local settings for Endpoint C
|
||||
[Interface]
|
||||
PrivateKey = wBu8AaHa061bI+6Eb+FmghV3iGKdp0a2Kq6At8UNzHo=
|
||||
Address = 10.0.0.3/24
|
||||
ListenPort = 51820
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = Fqd4WMaBpI7DAK6p2BaNhaE9VYzMRmfLxaO9uOmWTys=
|
||||
Endpoint = 172.16.0.122:51820
|
||||
AllowedIPs = 10.0.0.1/24
|
Loading…
x
Reference in New Issue
Block a user