From 2fbe10ca488e1b8360fbf16d7a90595de247b79b Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Thu, 6 May 2021 17:09:30 +0200 Subject: [PATCH] solution --- Readme.md | 15 ++--------- apache.yml | 9 ++++++- apache_correction.yml | 62 ------------------------------------------- 3 files changed, 10 insertions(+), 76 deletions(-) delete mode 100644 apache_correction.yml diff --git a/Readme.md b/Readme.md index 036691e..c67b0ab 100644 --- a/Readme.md +++ b/Readme.md @@ -1,16 +1,5 @@ ## Les tags -**Tâche**: Utiliser les tags pour n'exécuter qu'une sélection de tâches. +Toutes les tâches vont hériter de l'étiquette placée au niveau des //tasks// (ligne 17 de apache.yml) -**Condition**: Lors du développement d'un playbook, ou de l'utilisation d'un playbook volumineux. - -**Norme**: tags - -**Pratique**: Modifiez le playbook apache.yml afin de *tagguer* chaque tâche avec les étiquettes suivantes: - - * firewall (uniquement la tâche d'ouverture du parefeu) - * apache (toutes les tâches) - * docroot (uniquement les 2 dernières tâches) - - -Expérimentez en exécutant le playbook en utilisant les options --list-tasks et --tags ou --skip-tags +Sinon de manière plus classique les étiquettes peuvent ajouter à des tâches (lignes 39, 49, 56) diff --git a/apache.yml b/apache.yml index 90b14dc..e918e48 100644 --- a/apache.yml +++ b/apache.yml @@ -14,6 +14,7 @@ name: firewalld state: reloaded + tags: apache tasks: - name: install apache yum: @@ -35,6 +36,7 @@ enabled: yes - name: open firewall port + tags: firewall firewalld: service: http permanent: yes @@ -44,12 +46,17 @@ notify: reload firewalld - name: create documentroot + tags: + - docroot file: name: /var/www/html/orsys.fr state: directory - name: create index file + tags: + - docroot copy: src: index.html dest: /var/www/html/orsys.fr/index.html - mode: 0644 \ No newline at end of file + mode: 0644 + diff --git a/apache_correction.yml b/apache_correction.yml deleted file mode 100644 index 9df1298..0000000 --- a/apache_correction.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -- name: install apache via ansible playbook - hosts: test - user: ansible - become: true - handlers: - - name: reload httpd - service: - name: httpd - state: reloaded - - - name: reload firewalld - service: - name: firewalld - state: reloaded - - tags: apache - tasks: - - name: install apache - yum: - name: httpd - state: latest - - - name: conf httpd - notify: reload httpd - template: - src: vhost.conf - dest: /etc/httpd/conf.d/vhost.conf - mode: 0640 - owner: root - group: apache - - - name: activate apache - service: - name: httpd - enabled: yes - - - name: open firewall port - tags: firewall - firewalld: - service: http - permanent: yes - immediate: yes - state: enabled - ignore_errors: yes - notify: reload firewalld - - - name: create documentroot - tags: - - docroot - file: - name: /var/www/html/orsys.fr - state: directory - - - name: create index file - tags: - - docroot - copy: - src: index.html - dest: /var/www/html/orsys.fr/index.html - mode: 0644 -