From 4cd959e90016dbb41abf9e51f0e245f92d0db63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= <72651575+BreizhHardware@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:57:40 +0100 Subject: [PATCH] Obisidian vault auto-backup: 12-01-2026 11:57:40 on . 8 files edited --- .obsidian/workspace.json | 24 ++++----- .../CIPA4/TP Ansible/myplaybook.yml | 53 +++++++++++++++++++ .../CIPA4/TP Ansible/playbook-role.yml | 13 +++++ .../TP Ansible/roles/flask_app/tasks/main.yml | 22 ++++++++ .../roles/nginx_proxy/handlers/main.yml | 5 ++ .../roles/nginx_proxy/tasks/main.yml | 18 +++++++ .../roles/nginx_proxy/templates/nginx.conf.j2 | 10 ++++ .../CIPA4/TP Ansible/templates/nginx.conf.j2 | 10 ++++ 8 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/myplaybook.yml create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/playbook-role.yml create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks/main.yml create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers/main.yml create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks/main.yml create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates/nginx.conf.j2 create mode 100644 ISEN/Cloud Computing/CIPA4/TP Ansible/templates/nginx.conf.j2 diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index ee3b530..ba81f64 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -204,25 +204,26 @@ "obsidian-git:Open Git source control": false } }, - "active": "e11a6a080eb83632", + "active": "622da1d4e0ba0f73", "lastOpenFiles": [ + "ISEN/Cloud Computing/CIPA4/TP Ansible/templates/nginx.conf.j2", + "ISEN/Cloud Computing/CIPA4/TP Ansible/templates", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates/nginx.conf.j2", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers/main.yml", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks/main.yml", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks/main.yml", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/templates", + "ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks", "ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 1.md", "ISEN/Cloud Computing/CIPA4/TP 4 Ansible.md", "ISEN/Cloud Computing/CIPA4/TP 3 Ansible.md", "ISEN/Cloud Computing/CIPA4/TP 2 Ansible.md", "ISEN/Cloud Computing/CIPA4/TP 1 Ansible.md", "ISEN/Réunion/CIPA 4/Réunion 8 janv 2026.md", - "ISEN/Cloud Computing/CIPA4", - "ISEN/Cloud Computing", - "ISEN/Web/CIPA 4/TP/TP1/TP1_MARQUET.zip", - "ISEN/Web/CIPA 4/TP/TP1/Archive.zip", "ISEN/Web/CIPA 4/TP/TP1/images/ISEN_Logo.png", - "ISEN/Web/CIPA 4/TP/TP1/tp1.pdf", - "ISEN/Web/CIPA 4/TP/TP1/images", - "ISEN/Web/CIPA 4/TP/TP1/chat.html", - "ISEN/Web/CIPA 4/TP/TP1/authentification.html", - "ISEN/Web/CIPA 4/TP/TP1/accueil.html", - "ISEN/Web/CIPA 4/TP/TP1", "conflict-files-obsidian-git.md", "ISEN/Réunion/CIPA 4/Untitled.md", "ISEN/English/CIPA4/24 oct 2025.md", @@ -242,7 +243,6 @@ "ISEN/Réseau/A2/CCNA Cours 2.md", "ISEN/Réseau/A2/CCNA Cours 3.md", "Elevator.md", - "ISEN/JAVA/CIPA4/TP/TP2/TP2.md", "Pasted image 20251009192656.png", "src/Pasted image 20240130111505.png", "src/Pasted image 20240123120819.png", diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/myplaybook.yml b/ISEN/Cloud Computing/CIPA4/TP Ansible/myplaybook.yml new file mode 100644 index 0000000..0f0cadb --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/myplaybook.yml @@ -0,0 +1,53 @@ +--- +- hosts: demo + gather_facts: yes + tasks: + - name: Installer le paquet git + apt: + name: git + state: present + - name: Cloner mon application Flask + git: + repo: 'https://github.com/arnaudmorin/demo-flask.git' + dest: /root/demo-flask + - name: Installer pip + apt: + name: python3-pip + state: present + - name: Installer les dépendances Flask + pip: + requirements: /root/demo-flask/requirements.txt + - name: Démarrer l'application Flask en arrière-plan + shell: "nohup /root/demo-flask/start.sh &" + +- hosts: localhost + become: yes + vars: + proxy_port: 80 + flask_port: 8080 + server_name: "135.125.246.84" + tasks: + - name: Installer Nginx + apt: + name: nginx + state: present + - name: Configurer Nginx comme reverse proxy + template: + src: nginx.conf.j2 + dest: /etc/nginx/sites-available/demo + notify: Restart Nginx + - name: Activer la configuration du site + file: + src: /etc/nginx/sites-available/demo + dest: /etc/nginx/sites-enabled/demo + state: link + notify: Restart Nginx + - name: Afficher l'URL d'accès au site + debug: + msg: "Votre application est accessible à l'URL : http://{{ server_name }}" + + handlers: + - name: Restart Nginx + service: + name: nginx + state: restarted diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/playbook-role.yml b/ISEN/Cloud Computing/CIPA4/TP Ansible/playbook-role.yml new file mode 100644 index 0000000..4ede959 --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/playbook-role.yml @@ -0,0 +1,13 @@ +--- +- hosts: demo + roles: + - flask_app + +- hosts: localhost + become: yes + vars: + proxy_port: 80 + flask_port: 8080 + server_name: "135.125.246.84" + roles: + - role: nginx_proxy diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks/main.yml b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks/main.yml new file mode 100644 index 0000000..8bdfafc --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/flask_app/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: Installer le paquet git + apt: + name: git + state: present + +- name: Cloner l'application Flask + git: + repo: 'https://github.com/arnaudmorin/demo-flask.git' + dest: /root/demo-flask + +- name: Installer pip + apt: + name: python3-pip + state: present + +- name: Installer les dépendances Flask + pip: + requirements: /root/demo-flask/requirements.txt + +- name: Démarrer l'application Flask en arrière-plan + shell: "nohup /root/demo-flask/start.sh &" diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers/main.yml b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers/main.yml new file mode 100644 index 0000000..72d2e28 --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/handlers/main.yml @@ -0,0 +1,5 @@ +--- +- name: Restart Nginx + service: + name: nginx + state: restarted diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks/main.yml b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks/main.yml new file mode 100644 index 0000000..30b59ee --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/tasks/main.yml @@ -0,0 +1,18 @@ +--- +- name: Installer Nginx + apt: + name: nginx + state: present + +- name: Configurer Nginx comme reverse proxy + template: + src: nginx.conf.j2 + dest: /etc/nginx/sites-available/{{ server_name }} + notify: Restart Nginx + +- name: Activer la configuration du site + file: + src: /etc/nginx/sites-available/{{ server_name }} + dest: /etc/nginx/sites-enabled/{{ server_name }} + state: link + notify: Restart Nginx diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates/nginx.conf.j2 b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates/nginx.conf.j2 new file mode 100644 index 0000000..d65ba72 --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/roles/nginx_proxy/templates/nginx.conf.j2 @@ -0,0 +1,10 @@ +server { + listen {{ proxy_port }}; + server_name {{ server_name }}; + + location / { + proxy_pass http://127.0.0.2:{{ flask_port }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/ISEN/Cloud Computing/CIPA4/TP Ansible/templates/nginx.conf.j2 b/ISEN/Cloud Computing/CIPA4/TP Ansible/templates/nginx.conf.j2 new file mode 100644 index 0000000..d65ba72 --- /dev/null +++ b/ISEN/Cloud Computing/CIPA4/TP Ansible/templates/nginx.conf.j2 @@ -0,0 +1,10 @@ +server { + listen {{ proxy_port }}; + server_name {{ server_name }}; + + location / { + proxy_pass http://127.0.0.2:{{ flask_port }}; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } +}