version finale
This commit is contained in:
@@ -15,18 +15,54 @@
|
||||
|
||||
- name: creation dossier payara
|
||||
ansible.builtin.file:
|
||||
path: /home/debian/payara
|
||||
path: /SDIS-29-3.p2/ansible/payara
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: no
|
||||
|
||||
- name: importation
|
||||
- name: importation compose.yml
|
||||
ansible.builtin.copy:
|
||||
src: ./compose.yml
|
||||
dest: ~/paraya/compose.yml
|
||||
dest: /SDIS-29-3.p2/ansible/paraya/compose.yml
|
||||
mode: '0755'
|
||||
|
||||
- name: importation variables.env
|
||||
ansible.builtin.copy:
|
||||
src: ./variables.env
|
||||
dest: /SDIS-29-3.p2/ansible/paraya
|
||||
mode: '0755'
|
||||
become: no
|
||||
|
||||
- name: docker pull
|
||||
ansible.builtin.script:
|
||||
cmd: cd ~/payara ; docker compose pull
|
||||
|
||||
|
||||
- name: Création du fichier docker.service.d
|
||||
ansible.builtin.file:
|
||||
path: /etc/systemd/system/docker.service.d
|
||||
state: directory
|
||||
|
||||
- name: Copy des règles de proxy
|
||||
ansible.builtin.copy:
|
||||
src: ./http-proxy.conf
|
||||
dest: /etc/systemd/system/docker.service.d
|
||||
|
||||
- name: Restart daemon-reload
|
||||
ansible.builtin.shell:
|
||||
cmd:
|
||||
systemctl daemon-reload
|
||||
|
||||
- name: Docker restart
|
||||
ansible.builtin.service:
|
||||
name: docker
|
||||
state: restarted
|
||||
|
||||
- name: Docker pull
|
||||
ansible.builtin.shell:
|
||||
cmd:
|
||||
cd ~/payara && docker compose pull
|
||||
|
||||
- name: Docker up
|
||||
ansible.builtin.shell:
|
||||
cmd:
|
||||
cd ~/payara && docker compose up -d
|
||||
|
||||
40
vpn/README.md
Normal file
40
vpn/README.md
Normal file
@@ -0,0 +1,40 @@
|
||||
#mkwgconf.sh :
|
||||
|
||||
#Ce script crée un tunnel Wireguard en mode 'point-à-point' :
|
||||
|
||||
#- Il instaure les points d'extrémités de chaque machine A = test / B = prod.
|
||||
#- Il genere des clés Wireguard avec les variables "Endpoint".
|
||||
#- Il genere le fichier wg0-a.conf et wg0-b.conf
|
||||
|
||||
|
||||
#-----
|
||||
|
||||
#wp.yml
|
||||
|
||||
#Ce playbook s'occupe d' :
|
||||
|
||||
#- Installer Wireguard avec le "pkg"
|
||||
#- Copier le fichier 'mkwgconf.sh' dans ap33-test
|
||||
#- Lancement du script mkwgconf.sh dans test
|
||||
#- Copier le fichier wg.conf dans /etc/wireguard
|
||||
#- Récuperé le fichier wg0-b.conf dans test avec "fetch"
|
||||
#- Copié le fichier wg0-b.conf dans /etc/wireguard/wg0.conf avec "copy" pour le renommer
|
||||
#- Lancer le service Wireguard avec "systemd"
|
||||
#- Activer le service Wireguard avec "systemd"
|
||||
|
||||
#Pour lancer le playbook il faut mettre la commande suivante :
|
||||
|
||||
#ansible-playbook -i ap33-test,ap33-prod, wp.yml
|
||||
|
||||
#A présent il faut tester si tout fonctionne, pour cela il faut déja pouvori se connecter à ap33-test et ap33-prod, si une erreur se produit c'est qu'il manque la clé publique de la machine dans celle des distantes.
|
||||
#Pour regler le soucis :
|
||||
|
||||
#- Copier le contenu du fichier "id_rsa.pub" avec la commande "cat ~/.ssh/id_rsa.pub"
|
||||
#- Collé le contenu dans le fichier "authorized_keys" de chaque machine grâce à "echo "contenu id_rsa.pub" >> ~/.ssh/authorized_keys"
|
||||
#- Se connecter au différente machine avec "ssh debian@ap33-test" et "ssh debian@ap33-prod"
|
||||
|
||||
#Une fois connecté il faut voir si le VPN est activé :
|
||||
|
||||
#- Démarrer le service wg-quick avec "sudo systemctl enable --now wg-quick@wg0"
|
||||
#- Vérifier si cela fonctionne avec la commande "sudo wg"
|
||||
#- Ping avec les adresses VPN "ping 10.0.0.1" ou "ping 10.0.0.2"
|
||||
11
vpn/wg0-b.conf
Normal file
11
vpn/wg0-b.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
# local settings for Endpoint B
|
||||
[Interface]
|
||||
PrivateKey = ABG/4mDPr6zgTZKKInc81ooqOcwVmqCgM8iJ1HYHyGY=
|
||||
Address = 10.0.0.2/32
|
||||
ListenPort = 51820
|
||||
|
||||
# remote settings for Endpoint A
|
||||
[Peer]
|
||||
PublicKey = 5B4mfr7Rt47sC0iCvUMGfo1Vqkpko8FidiS9HU4woh8=
|
||||
Endpoint = 172.16.0.121:51820
|
||||
AllowedIPs = 10.0.0.1/32
|
||||
54
vpn/wp.yml
54
vpn/wp.yml
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user