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
|
||||
gather_facts: false
|
||||
hosts: centos
|
||||
handlers:
|
||||
- name: restart apache
|
||||
service:
|
||||
name: httpd
|
||||
state: restarted
|
||||
|
||||
tasks:
|
||||
- name: install apache
|
||||
yum:
|
||||
ansible.builtin.package:
|
||||
name: httpd
|
||||
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
|
||||
@@ -29,12 +40,12 @@
|
||||
ignore_errors: yes
|
||||
|
||||
- name: create documentroot
|
||||
file:
|
||||
name: /var/www/html/orsys.fr
|
||||
ansible.builtin.file:
|
||||
name: /var/www/html/example.org
|
||||
state: directory
|
||||
|
||||
- name: create index file
|
||||
copy:
|
||||
src: index.html
|
||||
dest: /var/www/html/orsys.fr/index.html
|
||||
ansible.builtin.copy:
|
||||
src: index.txt
|
||||
dest: /var/www/html/example.org/index.html
|
||||
mode: 0644
|
||||
|
||||
12
vhost.conf
12
vhost.conf
@@ -1,16 +1,16 @@
|
||||
<VirtualHost *:80>
|
||||
ServerName orsys.fr
|
||||
ServerAlias www.orsys.fr
|
||||
DocumentRoot /var/www/html/orsys.fr/
|
||||
CustomLog /var/log/httpd/orsys.fr_access.log combined
|
||||
ErrorLog /var/log/httpd/orsys.fr_error.log
|
||||
ServerName example.org
|
||||
ServerAlias www.example.org
|
||||
DocumentRoot /var/www/html/example.org/
|
||||
CustomLog /var/log/httpd/example.org_access.log combined
|
||||
ErrorLog /var/log/httpd/example.org_error.log
|
||||
<Directory />
|
||||
Options none
|
||||
Allowoverride none
|
||||
Require all denied
|
||||
</Directory>
|
||||
|
||||
<Directory /var/www/html/orsys.fr>
|
||||
<Directory /var/www/html/example.org>
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
Reference in New Issue
Block a user