Compare commits
2 Commits
solution
...
master_abr
| Author | SHA1 | Date | |
|---|---|---|---|
| 68929bc91d | |||
| 47b37fbcc8 |
20
Readme.md
20
Readme.md
@@ -10,14 +10,22 @@
|
|||||||
|
|
||||||
** Pratique **
|
** Pratique **
|
||||||
|
|
||||||
En examinant les différents fichiers présents dans ce dépôt, essayez de
|
Récupérer la solution de l'atelier handler
|
||||||
déterminez de quelle manière ce playbook a été adapté pour fonctionner aussi
|
|
||||||
bien sur une CentOS qu'une Debian.
|
|
||||||
|
|
||||||
La tâche "conf httpd" ne fonctionnera pas sur Debian. Pourquoi ? Proposez une solution.
|
Identifier dans le playbook et le fichier vhost.conf toutes les spécificités de RedHat (qui vont empécher le playbook de fonctionner)
|
||||||
|
|
||||||
|
Trouver la solution à cette problématique (exécution conditionnelle, variabilisation ...)
|
||||||
|
|
||||||
|
Implémenter la solution
|
||||||
|
|
||||||
|
Sur la debian, la configuration par défaut entre en conflit avec la notre:
|
||||||
|
|
||||||
|
Modifier le playbook pour que le fichier /etc/apache2/sites-enabled/000-default.conf soit supprimé UNIQUEMENT sur la debian, avec redémarrage du service apache si besoin
|
||||||
|
|
||||||
Ce playbook n'est pas complet. Déterminez les éléments manquants et corrigez.
|
|
||||||
|
|
||||||
** Validation:
|
** Validation:
|
||||||
|
|
||||||
le playbook s'exécute correctement sur la machine debian
|
```bash
|
||||||
|
curl debian1
|
||||||
|
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
||||||
|
```
|
||||||
72
apache.yml
72
apache.yml
@@ -1,72 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache via ansible playbook
|
|
||||||
hosts: all
|
|
||||||
handlers:
|
|
||||||
- name: restart apache
|
|
||||||
service:
|
|
||||||
name: "{{ apache_service_name }}"
|
|
||||||
state: restarted
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
|
|
||||||
- name: install apache
|
|
||||||
package:
|
|
||||||
name: "{{ apache_package_name }}"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: conf httpd
|
|
||||||
template:
|
|
||||||
src: vhost.conf
|
|
||||||
dest: "{{ apache_config_dir}}/vhost.conf"
|
|
||||||
mode: 0640
|
|
||||||
owner: root
|
|
||||||
group: apache
|
|
||||||
notify: restart apache
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
service:
|
|
||||||
name: "{{ apache_service_name }}"
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: remove default site conf
|
|
||||||
file:
|
|
||||||
path: /etc/apache2/sites-enabled/000-default.conf
|
|
||||||
state: absent
|
|
||||||
notify: restart apache
|
|
||||||
|
|
||||||
- name: setup firewall
|
|
||||||
block:
|
|
||||||
- name: install firewalld packages
|
|
||||||
yum:
|
|
||||||
name:
|
|
||||||
- python3-firewall
|
|
||||||
- firewalld
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: enable firewalld service
|
|
||||||
service:
|
|
||||||
name: firewalld
|
|
||||||
enabled: true
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: open firewall port
|
|
||||||
firewalld:
|
|
||||||
service: http
|
|
||||||
permanent: yes
|
|
||||||
immediate: yes
|
|
||||||
state: enabled
|
|
||||||
ignore_errors: true
|
|
||||||
when: ansible_distribution == 'CentOS'
|
|
||||||
|
|
||||||
|
|
||||||
- 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
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#/home/formation/sib_10_premier_playbook/centos.yml
|
|
||||||
apache_service_name: httpd
|
|
||||||
apache_package_name: httpd
|
|
||||||
apache_config_dir: /etc/httpd/conf.d
|
|
||||||
apache_log_dir: /var/log/httpd
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#/home/formation/sib_10_premier_playbook/debian.yml
|
|
||||||
apache_service_name: apache2
|
|
||||||
apache_package_name: apache2
|
|
||||||
apache_config_dir: /etc/apache2/sites-enabled/
|
|
||||||
apache_log_dir: /var/log/apache2
|
|
||||||
25
vhost.conf
25
vhost.conf
@@ -1,25 +0,0 @@
|
|||||||
#/home/formation/sib_10_premier_playbook/vhost.conf
|
|
||||||
<VirtualHost *:80>
|
|
||||||
ServerName example.org
|
|
||||||
ServerAlias www.example.org
|
|
||||||
ServerAlias {{ inventory_hostname }}
|
|
||||||
DocumentRoot /var/www/html/example.org
|
|
||||||
CustomLog {{ apache_log_dir }}/example.org_access.log combined
|
|
||||||
ErrorLog {{ apache_log_dir }}/example.org_error.log
|
|
||||||
<Directory />
|
|
||||||
Options none
|
|
||||||
Allowoverride none
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/html/example.org>
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
<Directory /var/www/html/example.org/Private>
|
|
||||||
Options indexes
|
|
||||||
AuthName "stop"
|
|
||||||
AuthType Basic
|
|
||||||
AuthUserFile /etc/{{ apache_service_name }}/passwd
|
|
||||||
require valid-user
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
Reference in New Issue
Block a user