Compare commits

..

2 Commits

5 changed files with 74 additions and 1 deletions

5
.env
View File

@ -8,4 +8,7 @@ KEYCLOAK_HOST_IP=172.16.32.134
KEYCLOAK_HOST=connect
# Portainer
PORTAINER_HOST=portainer
PORTAINER_HOST=portainer
# Pour mettre a jour, encrypter le mot de passe avec la commande suivante:
# htpasswd -nb -B admin "mot_de_passe" | cut -d ":" -f 2
PORTAINER_PASSWORD=$2y$05$gMMx0FiBvYmTo68jzlD0TekI2rhQgv4O7P6XwTWNFGojyC02I4RoC

3
ansible/ansible.cfg Normal file
View File

@ -0,0 +1,3 @@
[defaults]
inventory = hosts
host_key_checking = False

2
ansible/hosts Normal file
View File

@ -0,0 +1,2 @@
[servers]
ubuntu-server-vm ansible_host=172.16.32.141 ansible_user=k

64
ansible/playbook.yml Normal file
View File

@ -0,0 +1,64 @@
---
- name: Déploiement Docker et application via Docker Compose
hosts: servers
become: yes
vars:
git_repo: "https://gite.slm-lab.net/Chabdeltsang/Neah-Enkun.git"
git_dest: "/opt/Neah-Enkun"
git_branch: "master"
tasks:
- name: Mise à jour des paquets et montée de version
apt:
update_cache: yes
upgrade: dist
- name: Installer les dépendances pour Docker
apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
state: present
- name: Ajouter la clé GPG officielle de Docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Ajouter le dépôt Docker
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
- name: Installer Docker CE et ses composants
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: present
- name: Installer Docker Compose
apt:
name: docker-compose
state: present
- name: S'assurer que le service Docker est démarré et activé
service:
name: docker
state: started
enabled: yes
- name: Cloner le dépôt Git
git:
repo: "{{ git_repo }}"
dest: "{{ git_dest }}"
version: "{{ git_branch }}"
update: yes
- name: Lancer Docker Compose up
command: "docker compose up -d --build --remove-orphans"
args:
chdir: "{{ git_dest }}"

View File

@ -31,6 +31,7 @@ services:
- "traefik.enable=true"
- "traefik.http.routers.neah-portainer.rule=Host(`${PORTAINER_HOST}.${MAIN_DOMAIN}`)"
- "traefik.http.services.neah-portainer.loadbalancer.server.port=9000"
command: --admin-password='${PORTAINER_PASSWORD}'
networks:
- default