Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
| eadl:bloc4:fm2:td3 [2026/05/24 02:56] – jcheron | eadl:bloc4:fm2:td3 [2026/05/26 09:26] (Version actuelle) – [11. Execution et verification] jcheron | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | ====== | + | ====== |
| ===== Objectifs ===== | ===== Objectifs ===== | ||
| - | | + | A l' |
| - | * Configurer | + | |
| - | * Utiliser les groupes, variables et handlers Ansible | + | |
| - | * Identifier | + | * Configurer |
| + | * Ecrire des templates Jinja2 pour générer des fichiers de configuration dynamiques | ||
| + | * Utiliser les handlers | ||
| + | * Structurer un projet | ||
| + | * Gérer | ||
| + | * Utiliser des variables par environnement | ||
| ===== Contexte ===== | ===== Contexte ===== | ||
| - | Vous travaillez dans une equipe | + | Vous intégrez l' |
| + | L' | ||
| + | pour les environnements de developpement. | ||
| - | L'equipe doit deployer un environnement de developpement compose | + | Votre mission : automatiser la configuration d'une stack composee |
| - | * un frontend NGINX (page statique) | + | * un reverse proxy Nginx |
| - | * un backend Python | + | * une application |
| * une base de donnees PostgreSQL | * une base de donnees PostgreSQL | ||
| + | * un cache Redis | ||
| - | Probleme actuel : | + | Terraform a déjà provisionné les conteneurs. |
| + | Vous utilisez Ansible pour configurer. | ||
| - | * les developpeurs configurent les services a la main | + | ===== 0. Comprendre |
| - | * les environnements different d'une machine a l' | + | |
| - | * le backend demarre | + | |
| - | Objectif : | + | ==== 0.1 Rôles Ansible ==== |
| - | Automatiser le deploiement et la configuration de la stack complete. | + | Un rôle permet d’organiser : |
| - | ===== 1. Preparation du projet ===== | + | * tâches |
| + | * variables | ||
| + | * handlers | ||
| + | * templates | ||
| - | <sxh bash;gutter:false> | + | <WRAP round help> |
| - | mkdir td3-stack | + | Quel critère doit guider le découpage en rôles |
| - | cd td3-stack | + | ou l' |
| - | mkdir terraform ansible ansible/group_vars | + | </WRAP> |
| + | |||
| + | ==== 0.2 Structure d’un rôle ==== | ||
| + | |||
| + | < | ||
| + | roles/ | ||
| + | nginx/ | ||
| + | tasks/ | ||
| + | handlers/ | ||
| + | | ||
| </ | </ | ||
| - | Structure | + | ===== 1. Structure |
| - | <sxh; | + | Creez la structure suivante : |
| - | td3-stack/ | + | < |
| - | | + | td-ansible/ |
| - | | + | |
| - | | + | |
| - | | + | |
| - | ansible/ | + | main.tf |
| - | inventory.ini | + | ansible/ |
| - | | + | inventory/ |
| - | group_vars/ | + | hosts.yml |
| - | frontend.yml | + | group_vars/ |
| - | backend.yml | + | |
| - | | + | |
| + | backend.yml | ||
| + | db.yml | ||
| + | cache.yml | ||
| + | | ||
| + | nginx/ | ||
| + | tasks/ | ||
| + | main.yml | ||
| + | templates/ | ||
| + | nginx.conf.j2 | ||
| + | handlers/ | ||
| + | main.yml | ||
| + | flask/ | ||
| + | tasks/ | ||
| + | main.yml | ||
| + | handlers/ | ||
| + | main.yml | ||
| + | postgresql/ | ||
| + | tasks/ | ||
| + | main.yml | ||
| + | handlers/ | ||
| + | main.yml | ||
| + | redis/ | ||
| + | tasks/ | ||
| + | main.yml | ||
| + | handlers/ | ||
| + | main.yml | ||
| + | playbook.yml | ||
| </ | </ | ||
| + | ===== 2. Construction de l' | ||
| - | ===== 2. Provisionning Terraform ===== | + | <WRAP round todo> |
| + | Construisez l' | ||
| + | </ | ||
| - | ==== 2.1 Fichier de base ==== | + | Fichier : '' |
| + | |||
| + | <sxh bash> | ||
| + | FROM ubuntu: | ||
| + | |||
| + | RUN apt-get update -qq && \ | ||
| + | apt-get install -y -qq \ | ||
| + | openssh-server \ | ||
| + | python3 \ | ||
| + | python3-pip \ | ||
| + | sudo \ | ||
| + | curl \ | ||
| + | && mkdir -p /run/sshd \ | ||
| + | && echo ' | ||
| + | && sed -i ' | ||
| + | |||
| + | EXPOSE 22 | ||
| + | |||
| + | CMD ["/ | ||
| + | </ | ||
| + | |||
| + | <sxh bash> | ||
| + | cd docker | ||
| + | docker build -t ansible-node: | ||
| + | cd .. | ||
| + | </ | ||
| + | |||
| + | ===== 3. Provisionnement avec Terraform | ||
| + | |||
| + | <WRAP round todo> | ||
| + | Créez le fichier suivant, puis appliquez la configuration. | ||
| + | </ | ||
| Fichier : '' | Fichier : '' | ||
| Ligne 63: | Ligne 143: | ||
| required_providers { | required_providers { | ||
| docker = { | docker = { | ||
| - | source = " | + | source |
| + | version = "~> 3.0" | ||
| } | } | ||
| } | } | ||
| Ligne 70: | Ligne 151: | ||
| provider " | provider " | ||
| - | resource " | + | resource " |
| - | name = "nginx:latest" | + | name |
| + | keep_locally = true | ||
| } | } | ||
| - | resource "docker_image" "flask" { | + | resource "docker_network" "stack_network" { |
| - | name = "python: | + | name = "stack_network" |
| } | } | ||
| - | resource " | + | resource " |
| - | name = " | + | name = "nginx" |
| - | } | + | image = docker_image.base.image_id |
| - | + | ||
| - | resource " | + | |
| - | name = "frontend" | + | |
| - | image = docker_image.nginx.name | + | |
| networks_advanced { | networks_advanced { | ||
| - | name = docker_network.stack.name | + | name = docker_network.stack_network.name |
| + | } | ||
| + | ports { | ||
| + | internal = 22 | ||
| + | external = 2221 | ||
| } | } | ||
| - | |||
| ports { | ports { | ||
| internal = 80 | internal = 80 | ||
| - | external = 8080 | + | external = 8090 |
| } | } | ||
| } | } | ||
| - | resource " | + | resource " |
| - | name = "backend" | + | name = "flask" |
| - | image = docker_image.flask.name | + | image = docker_image.base.image_id |
| networks_advanced { | networks_advanced { | ||
| - | name = docker_network.stack.name | + | name = docker_network.stack_network.name |
| } | } | ||
| + | ports { | ||
| + | internal = 22 | ||
| + | external = 2222 | ||
| + | } | ||
| + | } | ||
| + | resource " | ||
| + | name = " | ||
| + | image = docker_image.base.image_id | ||
| + | networks_advanced { | ||
| + | name = docker_network.stack_network.name | ||
| + | } | ||
| ports { | ports { | ||
| - | internal = 5000 | + | internal = 22 |
| - | external = 5000 | + | external = 2223 |
| } | } | ||
| + | } | ||
| - | command = ["sleep", "infinity"] | + | resource |
| + | name = " | ||
| + | image = docker_image.base.image_id | ||
| + | networks_advanced { | ||
| + | name = docker_network.stack_network.name | ||
| + | } | ||
| + | ports { | ||
| + | internal = 22 | ||
| + | external = 2224 | ||
| + | } | ||
| } | } | ||
| + | </ | ||
| - | # A COMPLETER : image et conteneur PostgreSQL | + | <sxh bash> |
| - | # port interne : 5432, port externe : 5432 | + | cd terraform |
| - | # variable d' | + | terraform init |
| - | # connecte a td3-network | + | terraform apply |
| </ | </ | ||
| - | ==== 2.2 Outputs ==== | + | <WRAP round help> |
| + | Si vous obtenez une erreur indiquant que le réseau ou des conteneurs existent déjà, supprimez-les avant de relancer : | ||
| - | Fichier : '' | + | <sxh bash> |
| + | docker rm -f nginx flask postgresql redis | ||
| + | docker network rm stack_network | ||
| + | terraform | ||
| + | </sxh> | ||
| + | </ | ||
| - | <sxh js> | ||
| - | output " | ||
| - | value = " | ||
| - | } | ||
| - | output " | + | <WRAP round help> |
| - | value = "http:// | + | Questions |
| - | } | + | * Que fait terraform init ? |
| + | * Pourquoi expose-t-on le port 22 de chaque conteneur sur un port différent de la machine hôte ? | ||
| + | * Que se passe-t-il si deux conteneurs exposent le même port ? | ||
| + | </ | ||
| - | output " | + | ===== 4. Inventaire Ansible ===== |
| - | value = " | + | |
| - | } | + | |
| - | </ | + | |
| - | ==== 2.3 Deploiement ==== | + | L' |
| - | <sxh bash;gutter:false> | + | <WRAP round todo> |
| - | cd terraform | + | Creez le fichier suivant. |
| - | terraform init | + | |
| - | terraform apply | + | Fichier |
| + | </WRAP> | ||
| + | |||
| + | <sxh yaml> | ||
| + | all: | ||
| + | vars: | ||
| + | ansible_user: | ||
| + | ansible_password: | ||
| + | ansible_ssh_common_args: | ||
| + | |||
| + | children: | ||
| + | frontend: | ||
| + | hosts: | ||
| + | nginx: | ||
| + | ansible_host: | ||
| + | ansible_port: | ||
| + | |||
| + | backend: | ||
| + | hosts: | ||
| + | flask: | ||
| + | ansible_host: | ||
| + | ansible_port: | ||
| + | |||
| + | db: | ||
| + | hosts: | ||
| + | postgresql: | ||
| + | ansible_host: | ||
| + | ansible_port: | ||
| + | |||
| + | cache: | ||
| + | hosts: | ||
| + | redis: | ||
| + | ansible_host: | ||
| + | ansible_port: | ||
| </ | </ | ||
| <WRAP round todo> | <WRAP round todo> | ||
| - | Verifier que les trois conteneurs | + | Testez la connexion aux conteneurs |
| + | |||
| + | Installez au préalable sshpass sur votre machine | ||
| <sxh bash; | <sxh bash; | ||
| - | docker ps | + | sudo apt-get install -y sshpass |
| - | docker network inspect td3-network | + | </ |
| + | puis : | ||
| + | <sxh bash; | ||
| + | cd ansible/ | ||
| + | ansible all -i inventory/ | ||
| </ | </ | ||
| </ | </ | ||
| - | ===== 3. Inventaire | + | <WRAP round help> |
| + | Questions : | ||
| + | * Que signifie le parametre StrictHostKeyChecking=no ? | ||
| + | * Pourquoi est-ce acceptable en developpement mais pas en production ? | ||
| + | * Que retourne la commande ping d'Ansible | ||
| + | </ | ||
| - | Fichier : '' | ||
| - | <sxh ini> | + | ===== 5. Variables par groupe ===== |
| - | [frontend] | + | |
| - | localhost ansible_connection=local | + | |
| - | [backend] | + | Les variables permettent de centraliser la configuration et de la rendre reutilisable. |
| - | localhost ansible_connection=local | + | |
| - | [database] | + | <WRAP round todo> |
| - | localhost ansible_connection=local | + | Creez les fichiers suivants. |
| - | </sxh> | + | |
| - | ===== 4. Variables par groupe ===== | + | </ |
| - | Fichier : '' | + | |
| + | Fichier : ansible/ | ||
| <sxh yaml> | <sxh yaml> | ||
| - | container_name: frontend | + | app_name: ecommerce |
| - | html_content: "< | + | app_env: development |
| + | app_domain: localhost | ||
| </ | </ | ||
| - | Fichier : '' | + | Fichier : ansible/ |
| <sxh yaml> | <sxh yaml> | ||
| - | container_name: backend | + | db_name: ecommerce_db |
| - | flask_app: | | + | db_user: app_user |
| - | from flask import Flask | + | db_password: |
| - | app = Flask(__name__) | + | db_port: 5432 |
| + | </ | ||
| - | @app.route('/' | + | Fichier |
| - | def index(): | + | |
| - | return ' | + | |
| - | if __name__ == ' | + | <sxh yaml> |
| - | | + | redis_port: 6379 |
| - | packages: | + | redis_maxmemory: 256mb |
| - | - flask | + | |
| </ | </ | ||
| - | Fichier : '' | + | Fichier : ansible/ |
| <sxh yaml> | <sxh yaml> | ||
| - | container_name: database | + | flask_port: 5000 |
| - | db_user: postgres | + | flask_debug: true |
| - | db_name: appdb | + | db_host: postgresql |
| - | db_password: secret | + | cache_host: redis |
| </ | </ | ||
| - | ===== 5. Playbook ===== | + | Fichier : ansible/ |
| - | Fichier : '' | + | <sxh yaml> |
| + | nginx_port: 80 | ||
| + | backend_host: | ||
| + | backend_port: | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | ===== 6. Role PostgreSQL ===== | ||
| + | |||
| + | On commence par la base de donnees car les autres services en dependent. | ||
| + | |||
| + | <WRAP round todo> | ||
| + | Creez le fichier suivant. | ||
| + | |||
| + | Fichier : ansible/roles/ | ||
| + | </ | ||
| <sxh yaml> | <sxh yaml> | ||
| --- | --- | ||
| - | - name: Configuration frontend | + | - name: Installation de PostgreSQL |
| - | | + | |
| - | | + | |
| + | - postgresql | ||
| + | - postgresql-contrib | ||
| + | - python3-psycopg2 | ||
| + | state: present | ||
| + | update_cache: yes | ||
| - | tasks: | + | - name: Demarrage de PostgreSQL |
| - | | + | |
| - | | + | name: postgresql |
| - | | + | state: started |
| - | | + | |
| - | bash -c "echo '{{ html_content }}' > / | + | |
| - | | + | - name: Creation de la base de donnees |
| - | | + | |
| - | | + | |
| - | | + | postgresql_db: |
| + | name: " | ||
| + | state: present | ||
| - | - name: Configuration backend | + | - name: Creation de l' |
| - | | + | |
| - | | + | |
| + | postgresql_user: | ||
| + | name: "{{ db_user }}" | ||
| + | password: "{{ db_password }}" | ||
| + | state: present | ||
| + | - name: Attribution des privilègees | ||
| + | become: yes | ||
| + | become_user: | ||
| + | postgresql_privs: | ||
| + | database: "{{ db_name }}" | ||
| + | role: "{{ db_user }}" | ||
| + | privs: ALL | ||
| + | type: database | ||
| + | state: present | ||
| - | tasks: | + | </ |
| - | - name: Installer les dependances Python | + | |
| - | community.docker.docker_container_exec: | + | |
| - | container: "{{ container_name }}" | + | |
| - | command: pip install {{ packages | join(' ') }} | + | |
| - | - name: Copier le code Flask | + | ===== 7. Role Redis ===== |
| - | community.docker.docker_container_exec: | + | |
| - | container: "{{ container_name }}" | + | |
| - | command: > | + | |
| - | bash -c "cat > /app.py << ' | + | |
| - | {{ flask_app }} | + | |
| - | EOF" | + | |
| - | - name: Demarrer Flask | + | <WRAP round todo> |
| - | | + | Creez le fichier suivant. |
| - | container: "{{ container_name }}" | + | |
| - | command: bash -c "nohup python /app.py &" | + | |
| - | - name: Configuration base de donnees | + | Fichier |
| - | | + | </ |
| - | gather_facts: | + | |
| - | tasks: | + | <sxh yaml> |
| - | - name: Attendre que PostgreSQL soit pret | + | --- |
| - | | + | - name: Installation de Redis |
| - | | + | apt: |
| - | command: pg_isready | + | name: redis-server |
| - | | + | state: present |
| - | | + | |
| - | delay: 3 | + | |
| - | until: pg_ready.rc == 0 | + | |
| - | | + | - name: Configuration |
| - | | + | |
| - | | + | path: / |
| - | | + | regexp: ' |
| + | line: "maxmemory | ||
| + | | ||
| + | |||
| + | - name: Demarrage de Redis | ||
| + | service: | ||
| + | name: redis-server | ||
| + | state: started | ||
| + | enabled: yes | ||
| </ | </ | ||
| - | ==== 5.1 Premier lancement ==== | + | Fichier : ansible/ |
| - | < | + | < |
| - | cd ansible | + | --- |
| - | ansible-playbook | + | - name: restart redis |
| + | service: | ||
| + | name: redis-server | ||
| + | state: restarted | ||
| </ | </ | ||
| + | |||
| + | <WRAP round help> | ||
| + | Questions : | ||
| + | * Qu' | ||
| + | * Quand est-il declenché ? | ||
| + | * Quelle est la différence entre notify et un appel direct à service ? | ||
| + | </ | ||
| + | |||
| + | ===== 8. Role Flask ===== | ||
| <WRAP round todo> | <WRAP round todo> | ||
| - | Verifier que les services repondent : | + | Créez le fichier suivant. |
| - | <sxh bash; | + | Fichier |
| - | curl http://localhost: | + | |
| - | curl http://localhost: | + | |
| - | </ | + | |
| </ | </ | ||
| - | ==== 5.2 Deuxieme lancement ==== | + | <sxh yaml> |
| + | --- | ||
| + | - name: Installation des dependances Python | ||
| + | apt: | ||
| + | name: | ||
| + | - python3 | ||
| + | - python3-pip | ||
| + | - python3-venv | ||
| + | state: present | ||
| + | update_cache: | ||
| - | <WRAP round todo> | + | - name: Creation du repertoire applicatif |
| - | Relancer le playbook sans modifier quoi que ce soit : | + | file: |
| + | path: / | ||
| + | state: directory | ||
| + | mode: ' | ||
| - | <sxh bash;gutter:false> | + | - name: Creation de l' |
| - | ansible-playbook | + | copy: |
| + | dest: / | ||
| + | content: | | ||
| + | from flask import Flask, jsonify | ||
| + | import os | ||
| + | import redis | ||
| + | import psycopg2 | ||
| + | |||
| + | app = Flask(__name__) | ||
| + | |||
| + | @app.route('/ | ||
| + | def health(): | ||
| + | return jsonify(status=' | ||
| + | |||
| + | if __name__ == ' | ||
| + | app.run(host=' | ||
| + | notify: restart flask | ||
| + | |||
| + | - name: Installation de Flask et des dependances | ||
| + | pip: | ||
| + | name: | ||
| + | | ||
| + | - redis | ||
| + | - psycopg2-binary | ||
| + | executable: pip3 | ||
| + | |||
| + | - name: Creation du service systemd Flask | ||
| + | copy: | ||
| + | dest: / | ||
| + | content: | | ||
| + | [Unit] | ||
| + | Description=Flask Application | ||
| + | After=network.target | ||
| + | |||
| + | [Service] | ||
| + | Environment=APP_ENV={{ app_env }} | ||
| + | Environment=DB_HOST={{ db_host }} | ||
| + | Environment=CACHE_HOST={{ cache_host }} | ||
| + | ExecStart=/ | ||
| + | Restart=always | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=multi-user.target | ||
| + | notify: restart flask | ||
| + | |||
| + | - name: Demarrage de Flask | ||
| + | shell: nohup python3 / | ||
| + | args : | ||
| + | chdir: /opt/flask | ||
| </ | </ | ||
| - | Observer attentivement | + | Fichier : ansible/ |
| + | |||
| + | <sxh yaml> | ||
| + | --- | ||
| + | - name: restart flask | ||
| + | shell: pkill -f " | ||
| + | args : | ||
| + | chdir: / | ||
| + | </ | ||
| + | |||
| + | ===== 9. Role Nginx ===== | ||
| + | |||
| + | <WRAP round todo> | ||
| + | Créez | ||
| + | |||
| + | Fichier : ansible/ | ||
| </ | </ | ||
| + | |||
| + | <sxh yaml> | ||
| + | --- | ||
| + | - name: Installation de Nginx | ||
| + | apt: | ||
| + | name: nginx | ||
| + | state: present | ||
| + | update_cache: | ||
| + | |||
| + | - name: Configuration de Nginx | ||
| + | template: | ||
| + | src: nginx.conf.j2 | ||
| + | dest: / | ||
| + | mode: ' | ||
| + | notify: restart nginx | ||
| + | |||
| + | - name: Demarrage de Nginx | ||
| + | service: | ||
| + | name: nginx | ||
| + | state: started | ||
| + | enabled: yes | ||
| + | </ | ||
| + | |||
| + | Fichier : ansible/ | ||
| + | |||
| + | <sxh js> | ||
| + | upstream backend { | ||
| + | server {{ backend_host }}:{{ backend_port }}; | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen {{ nginx_port }}; | ||
| + | server_name {{ app_domain }}; | ||
| + | |||
| + | location / { | ||
| + | proxy_pass http:// | ||
| + | proxy_set_header Host $host; | ||
| + | proxy_set_header X-Real-IP $remote_addr; | ||
| + | } | ||
| + | |||
| + | location /health { | ||
| + | proxy_pass http:// | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Fichier : ansible/ | ||
| + | |||
| + | <sxh yaml> | ||
| + | --- | ||
| + | - name: restart nginx | ||
| + | service: | ||
| + | name: nginx | ||
| + | state: restarted | ||
| + | </ | ||
| <WRAP round help> | <WRAP round help> | ||
| Questions : | Questions : | ||
| + | * Quelle est la difference entre copy et template dans Ansible ? | ||
| + | * Que fait la directive proxy_pass ? | ||
| + | * Pourquoi utilise-t-on le nom du conteneur plutôt que son adresse IP ? | ||
| + | </ | ||
| - | * Quelles taches echouent ? Pour quelle raison precise ? | + | ===== 10. Playbook principal ===== |
| - | * Parmi les taches qui reussissent, | + | |
| - | * Qu' | + | <WRAP round todo> |
| - | * Comment corrigeriez-vous chaque tache concernee ? | + | Creez le fichier suivant. |
| + | |||
| + | Fichier : ansible/ | ||
| </ | </ | ||
| - | ===== 6. Challenge | + | <sxh yaml> |
| + | --- | ||
| + | - name: Configuration de la base de donnees | ||
| + | hosts: db | ||
| + | become: yes | ||
| + | roles: | ||
| + | - postgresql | ||
| + | |||
| + | - name: Configuration du cache | ||
| + | hosts: cache | ||
| + | become: yes | ||
| + | roles: | ||
| + | - redis | ||
| + | |||
| + | - name: Configuration de l' | ||
| + | hosts: backend | ||
| + | become: yes | ||
| + | roles: | ||
| + | - flask | ||
| + | |||
| + | - name: Configuration du reverse proxy | ||
| + | hosts: frontend | ||
| + | become: yes | ||
| + | roles: | ||
| + | - nginx | ||
| + | </ | ||
| + | |||
| + | <WRAP round help> | ||
| + | Questions : | ||
| + | * Pourquoi l' | ||
| + | * Que se passe-t-il si on configure Nginx avant Flask ? | ||
| + | * A quoi sert le parametre become ? | ||
| + | </ | ||
| + | |||
| + | ===== 11. Execution et verification | ||
| <WRAP round todo> | <WRAP round todo> | ||
| - | Ajouter un reverse proxy devant la stack. | + | Executez le playbook : |
| - | Specifications : | + | cd ansible/ |
| + | ansible-playbook -i inventory/ | ||
| - | * image : nginx: | + | Verifiez que l' |
| - | * nom du conteneur : proxy | + | |
| - | * port externe : 80 | + | |
| - | * connecte a td3-network | + | |
| - | * rediriger / vers le frontend et /api vers le backend | + | |
| - | Contrainte | + | curl http:// |
| </ | </ | ||
| - | ===== 7. Bonus ===== | + | ===== 12. Problème volontaire |
| <WRAP round todo> | <WRAP round todo> | ||
| - | Generer l' | + | Modifiez le fichier group_vars/ |
| - | <sxh bash;gutter:false> | + | backend_host: wronghost |
| - | cd terraform | + | |
| - | terraform output -json > ../ | + | |
| - | </ | + | |
| - | Ecrire un script qui lit '' | + | Relancez le playbook, puis testez : |
| - | Le resultat doit etre identique a l' | + | curl http:// |
| </ | </ | ||
| <WRAP round help> | <WRAP round help> | ||
| - | Question | + | Questions |
| + | * Que se passe-t-il et pourquoi ? | ||
| + | * Comment Ansible vous aide-t-il a identifier le probleme ? | ||
| + | * Ou dans les logs trouvez-vous l' | ||
| + | * Comment corriger ? | ||
| + | </ | ||
| - | * Dans quel cas cet inventaire genere devient-il indispensable par rapport a un inventaire ecrit a la main ? | + | <WRAP round todo> |
| + | Corrigez | ||
| + | Vérifiez que l' | ||
| </ | </ | ||
| + | ===== 13. Challenge final ===== | ||
| + | |||
| + | Vous devez ajouter un nouveau service de monitoring. | ||
| + | |||
| + | <WRAP round todo> | ||
| + | Sans aide, créez un rôle Ansible pour installer et configurer Netdata sur le conteneur flask. | ||
| + | |||
| + | Contraintes : | ||
| + | * Le service doit demarrer automatiquement | ||
| + | * Le port d' | ||
| + | * Un handler doit gérer le redémarrage | ||
| + | * Le conteneur flask doit exposer le port correspondant dans main.tf | ||
| + | |||
| + | Vérifiez que Netdata est accessible depuis votre navigateur. | ||
| + | </ | ||
| + | |||
| + | ===== Bonus ===== | ||
| + | |||
| + | <WRAP round todo> | ||
| + | * Ajoutez un tag Ansible sur chaque play pour pouvoir executer uniquement un rôle spécifique | ||
| + | * Créez un fichier ansible.cfg pour éviter de spécifier l' | ||
| + | * Chiffrez le fichier group_vars/ | ||
| + | </ | ||