Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df32926ad2 | |||
| f5669f671d | |||
| 07eb50aeea | |||
| d8f1b79189 | |||
| da43eabcbe | |||
| 312335742f | |||
| 072a555f21 | |||
| 33c48d2b74 | |||
| d3dd99b100 |
11
Readme.md
11
Readme.md
@@ -1,11 +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.
|
|
||||||
|
|
||||||
Attention, il vous faudra rajouter la directive *hosts* dans le playbook.
|
|
||||||
31
apache.yml
31
apache.yml
@@ -1,27 +1,38 @@
|
|||||||
---
|
---
|
||||||
- name: install apache via ansible playbook
|
- name: install apache via ansible playbook
|
||||||
gather_facts: false
|
hosts: centos
|
||||||
|
handlers:
|
||||||
|
- name: restart apache
|
||||||
|
service:
|
||||||
|
name: httpd
|
||||||
|
state: restarted
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: install apache
|
- name: install apache
|
||||||
yum:
|
ansible.builtin.package:
|
||||||
name: httpd
|
name: httpd
|
||||||
state: latest
|
state: latest
|
||||||
|
|
||||||
- name: conf httpd
|
- name: conf httpd
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: vhost.conf
|
src: vhost.conf
|
||||||
dest: /etc/httpd/conf.d/vhost.conf
|
dest: /etc/httpd/conf.d/vhost.conf
|
||||||
mode: 0640
|
mode: 0640
|
||||||
owner: root
|
owner: root
|
||||||
group: apache
|
group: apache
|
||||||
|
notify: restart apache
|
||||||
|
|
||||||
|
- name: call handlers, if needed
|
||||||
|
ansible.builtin.meta: flush_handlers
|
||||||
|
|
||||||
- name: activate apache
|
- name: activate apache
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: httpd
|
name: httpd
|
||||||
enabled: yes
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
|
||||||
- name: open firewall port
|
- name: open firewall port
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: http
|
service: http
|
||||||
permanent: yes
|
permanent: yes
|
||||||
immediate: yes
|
immediate: yes
|
||||||
@@ -29,12 +40,12 @@
|
|||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- name: create documentroot
|
- name: create documentroot
|
||||||
file:
|
ansible.builtin.file:
|
||||||
name: /var/www/html/orsys.fr
|
name: /var/www/html/example.org
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: create index file
|
- name: create index file
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: index.html
|
src: index.txt
|
||||||
dest: /var/www/html/orsys.fr/index.html
|
dest: /var/www/html/example.org/index.html
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|||||||
12
vhost.conf
12
vhost.conf
@@ -1,16 +1,16 @@
|
|||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerName orsys.fr
|
ServerName example.org
|
||||||
ServerAlias www.orsys.fr
|
ServerAlias www.example.org
|
||||||
DocumentRoot /var/www/html/orsys.fr/
|
DocumentRoot /var/www/html/example.org/
|
||||||
CustomLog /var/log/httpd/orsys.fr_access.log combined
|
CustomLog /var/log/httpd/example.org_access.log combined
|
||||||
ErrorLog /var/log/httpd/orsys.fr_error.log
|
ErrorLog /var/log/httpd/example.org_error.log
|
||||||
<Directory />
|
<Directory />
|
||||||
Options none
|
Options none
|
||||||
Allowoverride none
|
Allowoverride none
|
||||||
Require all denied
|
Require all denied
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Directory /var/www/html/orsys.fr>
|
<Directory /var/www/html/example.org>
|
||||||
Require all granted
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
Reference in New Issue
Block a user