From 7d9efbe98a612ea415a167833993f01efe4c2740 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Thu, 7 May 2020 17:36:26 +0200 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20workshop=201er=20playbook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit typoe readme --- 10_premier_playbook/Readme.md | 24 ++++++++++++++++-------- 10_premier_playbook/apache.yml | 25 ++++++++++++++++++++++--- 10_premier_playbook/index.html | 1 - 10_premier_playbook/vhost.conf | 17 ----------------- 4 files changed, 38 insertions(+), 29 deletions(-) delete mode 100644 10_premier_playbook/index.html delete mode 100644 10_premier_playbook/vhost.conf diff --git a/10_premier_playbook/Readme.md b/10_premier_playbook/Readme.md index f19b069..f720ba5 100644 --- a/10_premier_playbook/Readme.md +++ b/10_premier_playbook/Readme.md @@ -1,14 +1,22 @@ 1er playbook: installer apache ----- -Écrire le playbook permettant sur la machine **centos** uniquement: +*Tâche*: déployer un serveur apache à l'aide d'ansible - 1. d'installer le serveur apache - 2. d'ouvrir le parefeu - 3. de créer le répertoire correspondant au documentRoot - 4. de déployer le fichier /srv/vhost.conf dans /etc/httpd/conf.d/ - 5. de déployer le fichier /srv/index.html dans le répertoire correspondant au documentRoot - 6. d'activer le service - 6. de lancer le service +*Condition*: déploiement d'un serveur apache + +*Norme*: playbook et ansible-playbook + +*Pratique*: Écrire le playbook permettant sur la machine **centos** uniquement: + + 1. récupère sur le pilote les fichiers https://cours.opendoor.fr/Fichiers/SIB/index.html et vhost.conf - le fichier index.txt sera renommé en index.html + 2. d'installer le serveur apache + 3. d'ouvrir le parefeu + 4. de créer le répertoire correspondant au documentRoot + 5. de déployer le fichier /srv/vhost.conf dans /etc/httpd/conf.d/ + 6. de déployer le fichier /srv/index.html dans le répertoire correspondant au documentRoot + 7. d'activer le service + 8. de lancer le service + 9. de supprimer les fichiers à l'étape #1 Validation: on doit pouvoir se connecter en http sur la machine cible \ No newline at end of file diff --git a/10_premier_playbook/apache.yml b/10_premier_playbook/apache.yml index d4ceab2..353e669 100644 --- a/10_premier_playbook/apache.yml +++ b/10_premier_playbook/apache.yml @@ -1,6 +1,25 @@ --- - name: install apache via ansible playbook - hosts: all + hosts: amue-sib-centos-01.formation.actilis.fr + + pre_tasks: + - name: get ressources + get_url: + url: "{{ item }}" + dest: /tmp + loop: + - https://cours.opendoor.fr/Fichiers/SIB/index.txt + - https://cours.opendoor.fr/Fichiers/SIB/vhost.conf + delegate_to: localhost + + post_tasks: + - name: cleanup + file: + path: "{{ item }}" + state: absent + loop: + - /tmp/index.txt + - /tmp/vhost.conf tasks: - name: install apache @@ -10,7 +29,7 @@ - name: conf httpd template: - src: vhost.conf + src: /tmp/vhost.conf dest: /etc/httpd/conf.d/vhost.conf mode: 0640 owner: root @@ -36,6 +55,6 @@ - name: copy index file copy: - src: index.html + src: /tmp/index.txt dest: /var/www/html/orsys.fr/index.html mode: 0644 \ No newline at end of file diff --git a/10_premier_playbook/index.html b/10_premier_playbook/index.html deleted file mode 100644 index 9daeafb..0000000 --- a/10_premier_playbook/index.html +++ /dev/null @@ -1 +0,0 @@ -test diff --git a/10_premier_playbook/vhost.conf b/10_premier_playbook/vhost.conf deleted file mode 100644 index b352f6d..0000000 --- a/10_premier_playbook/vhost.conf +++ /dev/null @@ -1,17 +0,0 @@ - - ServerName orsys.fr - ServerAlias www.orsys.fr - ServerAlias 100.0.0.100 - DocumentRoot /var/www/html/orsys.fr/ - CustomLog /var/log/httpd/orsys.fr_access.log combined - ErrorLog /var/log/httpd/orsys.fr_error.log - - Options none - Allowoverride none - Require all denied - - - - Require all granted - - \ No newline at end of file