From 250b199feaabac7c4ea2d0748f1b94729ecc7ab9 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Tue, 16 Mar 2021 22:14:17 +0100 Subject: [PATCH] solution --- Readme.md | 23 ----------------------- apache.yml | 42 +++++++++--------------------------------- centos.yml | 2 ++ debian.yml | 2 ++ 4 files changed, 13 insertions(+), 56 deletions(-) delete mode 100644 Readme.md create mode 100644 centos.yml create mode 100644 debian.yml diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 64f7b74..0000000 --- a/Readme.md +++ /dev/null @@ -1,23 +0,0 @@ -## Includes et import - -**Tâche**: écrire des playbooks modulaires - -**Condition**: selon besoin - -**Norme**: includes et import - -**Préparation**: - -** Pratique ** - -Adapter le playbook apache.yml pour qu'il fonctionne sur la machine _debian_: - - 1. identifiez les différences entre OS (nom des packages, des services, répertoires différents, ...) - 2. essayez de trouver une solution permettant de gérer ses différences. - -** Validation: - -le playbook s'exécute correctement sur la machine debian - -Chaque cible héberge plusieurs sites différents. -Proposition de solution: voir la branche "solution" \ No newline at end of file diff --git a/apache.yml b/apache.yml index 7d8b597..84ab241 100644 --- a/apache.yml +++ b/apache.yml @@ -1,42 +1,18 @@ --- - name: install apache via ansible playbook - hosts: centos + hosts: cibles tasks: - - name: install apache - yum: - name: httpd - state: present + - name: import OS Specific variables + include_vars: "{{ ansible_distribution | lower }}.yml" - - name: conf httpd - template: - src: vhost.conf - dest: /etc/httpd/conf.d/vhost.conf - mode: 0640 - owner: root - group: apache + - name: install apache + package: + name: "{{ apache_package_name }}" + state: present - name: activate apache service: - name: httpd + name: "{{ apache_service_name }}" enabled: yes - state: started - - - name: open firewall port - firewalld: - service: http - permanent: yes - immediate: yes - state: enabled - ignore_errors: true - - - name: create documentroot - file: - name: /var/www/html/example.org/ - state: directory - - - name: copy index file - template: - src: index.txt - dest: /var/www/html/example.org/index.html - mode: 0644 \ No newline at end of file + state: started \ No newline at end of file diff --git a/centos.yml b/centos.yml new file mode 100644 index 0000000..e64dc5c --- /dev/null +++ b/centos.yml @@ -0,0 +1,2 @@ +apache_package_name: httpd +apache_service_name: httpd \ No newline at end of file diff --git a/debian.yml b/debian.yml new file mode 100644 index 0000000..2403f7f --- /dev/null +++ b/debian.yml @@ -0,0 +1,2 @@ +apache_package_name: apache2 +apache_service_name: apache2 \ No newline at end of file