Compare commits

9 Commits

Author SHA1 Message Date
df32926ad2 fqcn'd 2025-09-23 10:20:19 +02:00
f5669f671d flush 2022-11-14 14:01:12 +01:00
07eb50aeea typo 2022-11-14 13:52:44 +01:00
d8f1b79189 typo 2022-07-01 09:04:48 +02:00
da43eabcbe typo 2021-05-11 09:46:37 +02:00
312335742f Merge branch 'solution' of ssh://infra.opendoor.fr:2222/srv/git/repos/tom/sib_12_handlers into solution 2021-04-20 10:02:13 +02:00
072a555f21 solution 2021-04-20 09:59:18 +02:00
33c48d2b74 solution 2021-04-20 09:57:12 +02:00
d3dd99b100 solution 2021-03-16 21:51:14 +01:00
3 changed files with 21 additions and 25 deletions

View File

@@ -1,13 +0,0 @@
## 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,42 +1,51 @@
---
- name: install apache via ansible playbook
hosts: centos
handlers:
- name: restart apache
service:
name: httpd
state: restarted
tasks:
- name: install apache
yum:
ansible.builtin.package:
name: httpd
state: present
state: latest
- name: conf httpd
template:
ansible.builtin.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
service:
ansible.builtin.service:
name: httpd
enabled: yes
state: started
- name: open firewall port
firewalld:
ansible.posix.firewalld:
service: http
permanent: yes
immediate: yes
state: enabled
ignore_errors: true
ignore_errors: yes
- name: create documentroot
file:
name: /var/www/html/example.org/
ansible.builtin.file:
name: /var/www/html/example.org
state: directory
- name: copy index file
template:
- name: create index file
ansible.builtin.copy:
src: index.txt
dest: /var/www/html/example.org/index.html
mode: 0644
mode: 0644

View File

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