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:intro [2026/04/25 14:36] – jcheron | eadl:bloc4:fm2:intro [2026/04/30 01:58] (Version actuelle) – jcheron | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ====== Introduction à l' | ====== Introduction à l' | ||
| + | |||
| + | < | ||
| + | On apprend à déployer une infra de façon reproductible, | ||
| + | </ | ||
| ===== Objectifs ===== | ===== Objectifs ===== | ||
| Ligne 37: | Ligne 41: | ||
| ===== 2. Problème : gestion manuelle ===== | ===== 2. Problème : gestion manuelle ===== | ||
| - | En pratique, sans IaC : | + | En pratique, sans automatisation |
| * actions manuelles (console, SSH) | * actions manuelles (console, SSH) | ||
| Ligne 43: | Ligne 47: | ||
| * pas versionné | * pas versionné | ||
| - | Exemple concret | + | Exemples concrets |
| - | * un admin ouvre un port " | + | * un port ouvert |
| - | * personne ne le documente | + | * configuration différente entre dev et prod |
| - | * faille de sécurité | + | * perte d’informations lors d’un redéploiement |
| - | + | ||
| - | Autre exemple : | + | |
| - | + | ||
| - | * en prod : port 8080 | + | |
| - | * en dev : port 3000 | + | |
| - | * bug uniquement en prod | + | |
| <WRAP round help> | <WRAP round help> | ||
| Ligne 61: | Ligne 59: | ||
| </ | </ | ||
| - | ===== 3. Idée clé : traiter l’infrastructure comme du code ===== | + | ===== 3. Micro-exercice |
| - | Principe | + | Objectif |
| - | * on écrit | + | Comprendre la difficulté de reproduire |
| - | * on versionne (Git) | + | |
| - | * on exécute | + | |
| - | Analogie : | + | ==== Étape 1 ==== |
| - | * avant : cuisine "à l’œil" | + | Fichier |
| - | * maintenant : recette écrite | + | |
| - | Exemple | + | <sxh bash;gutter:false> |
| + | docker run -d -p 8081:80 --name test_nginx nginx | ||
| + | </ | ||
| - | Avant : | + | <WRAP round todo> |
| - | * cliquer dans une interface | + | Validation |
| - | * lancer des commandes à la main | + | |
| - | Après | + | * Ouvrir http:// |
| - | * fichier versionné | + | </ |
| - | * reproductible à l’identique | + | |
| - | ===== 4. Exemple simple ===== | + | ==== Étape 2 ==== |
| + | |||
| + | Fichier : terminal | ||
| + | |||
| + | <sxh bash; | ||
| + | echo "< | ||
| + | docker cp index.html test_nginx:/ | ||
| + | </ | ||
| + | |||
| + | <WRAP round todo> | ||
| + | Validation : | ||
| + | |||
| + | * Rafraîchir la page | ||
| + | </ | ||
| + | |||
| + | ==== Étape 3 ==== | ||
| + | |||
| + | Fichier : terminal | ||
| + | |||
| + | <sxh bash; | ||
| + | docker rm -f test_nginx | ||
| + | docker run -d -p 8081:80 --name test_nginx nginx | ||
| + | </ | ||
| + | |||
| + | <WRAP round help> | ||
| + | Questions : | ||
| + | |||
| + | * Que s’est-il passé ? | ||
| + | * Pourquoi la modification a disparu ? | ||
| + | </ | ||
| + | |||
| + | ===== 4. Transition ===== | ||
| + | |||
| + | Sans automatisation : | ||
| + | |||
| + | * les modifications sont perdues | ||
| + | * rien n’est tracé | ||
| + | * difficile à reproduire | ||
| + | |||
| + | <WRAP round help> | ||
| + | Question : | ||
| + | |||
| + | * Comment éviter ce problème dans une équipe ? | ||
| + | </ | ||
| + | |||
| + | ===== 5. Définition de l’Infrastructure as Code ===== | ||
| + | |||
| + | Principe : | ||
| + | |||
| + | * décrire l’infrastructure avec du code | ||
| + | * versionner ce code (Git) | ||
| + | * exécuter automatiquement | ||
| + | |||
| + | Analogie : | ||
| + | |||
| + | * avant : configuration "à la main" | ||
| + | * après : recette écrite et reproductible | ||
| + | |||
| + | ===== 6. Exemple simple ===== | ||
| Objectif : | Objectif : | ||
| - | * lancer | + | * obtenir |
| Sans IaC : | Sans IaC : | ||
| - | * docker run -p 8080:80 nginx | + | * commandes manuelles |
| - | * copier les fichiers à la main | + | * étapes non tracées |
| Avec IaC : | Avec IaC : | ||
| - | * un fichier Terraform crée le conteneur | + | * fichier Terraform |
| - | * un playbook Ansible configure le contenu | + | * playbook Ansible |
| Résultat : | Résultat : | ||
| - | * même résultat pour toute l’équipe | ||
| * reproductible | * reproductible | ||
| - | * automatisable | + | * automatisé |
| + | * partagé avec l’équipe | ||
| - | ===== 5. Déclaratif vs Impératif ===== | + | ===== 7. Déclaratif vs Impératif ===== |
| ==== Approche impérative ==== | ==== Approche impérative ==== | ||
| - | On donne les étapes : | + | On décrit |
| * installer nginx | * installer nginx | ||
| * démarrer le service | * démarrer le service | ||
| - | Problème | + | Limite |
| * dépend de l’état initial | * dépend de l’état initial | ||
| - | * plus fragile | ||
| ==== Approche déclarative ==== | ==== Approche déclarative ==== | ||
| Ligne 124: | Ligne 176: | ||
| On décrit le résultat : | On décrit le résultat : | ||
| - | * "je veux un serveur web accessible" | + | * "je veux un serveur web" |
| - | L’outil | + | L’outil |
| - | + | ||
| - | * quoi créer | + | |
| - | * quoi modifier | + | |
| <WRAP round help> | <WRAP round help> | ||
| Question : | Question : | ||
| - | * Pourquoi | + | * Pourquoi |
| </ | </ | ||
| - | ===== 6. Terraform vs Ansible ===== | + | ===== 8. Terraform vs Ansible ===== |
| Terraform : | Terraform : | ||
| * crée l’infrastructure | * crée l’infrastructure | ||
| - | * sait ce qu’il a créé | + | * maintient un état (state) |
| Ansible : | Ansible : | ||
| - | * configure les machines | + | * configure les systèmes |
| - | * agit directement sur le système | + | * exécute des tâches |
| - | Exemple | + | Exemple : |
| * Terraform → crée un conteneur | * Terraform → crée un conteneur | ||
| - | * Ansible → copie une page HTML dedans | + | * Ansible → modifie son contenu |
| - | ===== 7. Workflow | + | ===== 9. Workflow |
| - | + | ||
| - | Dans une entreprise : | + | |
| * Terraform → infrastructure | * Terraform → infrastructure | ||
| * Ansible → configuration | * Ansible → configuration | ||
| - | * CI/CD → déploiement applicatif | + | * pipeline |
| Chaîne : | Chaîne : | ||
| - | Code → Infra → Config | + | Code → Infrastructure |
| - | ===== 8. Transition vers le TD ===== | + | ===== 10. Transition vers le TD ===== |
| - | Dans le TD : | + | Dans le TD suivant |
| - | * vous allez créer un conteneur | + | * vous allez automatiser ce que vous venez de faire manuellement |
| - | * puis le modifier avec Ansible | + | * créer un service |
| + | * le modifier avec Ansible | ||
| Objectif : | Objectif : | ||
| - | * comprendre la séparation | + | * comprendre la complémentarité |
| - | * observer les limites si on mélange tout | + | |
| - | ===== 9. À retenir ===== | + | ===== 11. À retenir ===== |
| - | * IaC = automatiser l’infrastructure | + | * IaC = infrastructure |
| - | * réduire les erreurs humaines | + | * objectif : reproductibilité et fiabilité |
| - | * rendre les environnements reproductibles | + | * Terraform → provisioning |
| - | * Terraform et Ansible | + | * Ansible |