Compare commits

7 Commits

Author SHA1 Message Date
0f231ee7cf flush 2022-11-14 13:59:49 +01:00
b9f189bcfb typo 2022-11-14 13:51:53 +01:00
823ddf1ae2 ajout index.txt 2021-11-15 16:56:55 +01:00
5cfbe08e66 typoe 2021-06-08 16:22:46 +02:00
19ca29be0b typo 2021-05-11 09:46:00 +02:00
2dd9eb923a rajout apache.yml 2021-03-16 21:54:21 +01:00
20b3b4caa1 solution 2021-03-16 21:52:03 +01:00
3 changed files with 25 additions and 21 deletions

13
Readme.md Normal file
View File

@@ -0,0 +1,13 @@
## Les handlers
**Tâche**: Relancer un service uniquement en cas de modification de la configuration
**Condition**: déploiement d'un service
**Norme**: handler
**Pratique**: Modifiez le playbook apache.yml afin que le déploiement d'une nouvelle version du fichier vhost.conf entraîne un redémarrage du service apache.
Solution: voir branche "solution"
Pratique bis: utiliser le module _ansible.builtin.meta_ afin de forcer l'exécution du handler (si besoin) juste après la tâche "conf httpd"

View File

@@ -1,51 +1,42 @@
---
- name: install apache via ansible playbook
hosts: centos
handlers:
- name: restart apache
service:
name: httpd
state: restarted
tasks:
- name: install apache
ansible.builtin.package:
yum:
name: httpd
state: latest
state: present
- name: conf httpd
ansible.builtin.template:
template:
src: vhost.conf
dest: /etc/httpd/conf.d/vhost.conf
mode: 0640
owner: root
group: apache
notify: restart apache
- name: call handlers, if needed
ansible.builtin.meta: flush_handlers
- name: activate apache
ansible.builtin.service:
service:
name: httpd
enabled: yes
state: started
- name: open firewall port
ansible.posix.firewalld:
firewalld:
service: http
permanent: yes
immediate: yes
state: enabled
ignore_errors: yes
ignore_errors: true
- name: create documentroot
ansible.builtin.file:
name: /var/www/html/example.org
file:
name: /var/www/html/example.org/
state: directory
- name: create index file
ansible.builtin.copy:
- name: copy index file
template:
src: index.txt
dest: /var/www/html/example.org/index.html
mode: 0644
mode: 0644

View File

@@ -1 +1 @@
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
<h1>hello World</h1>