Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0f231ee7cf | |||
| b9f189bcfb | |||
| 823ddf1ae2 | |||
| 5cfbe08e66 | |||
| 19ca29be0b | |||
| 2dd9eb923a | |||
| 20b3b4caa1 |
@@ -8,4 +8,6 @@
|
||||
|
||||
**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.
|
||||
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"
|
||||
|
||||
20
apache.yml
20
apache.yml
@@ -1,11 +1,12 @@
|
||||
---
|
||||
- name: install apache via ansible playbook
|
||||
gather_facts: false
|
||||
hosts: centos
|
||||
|
||||
tasks:
|
||||
- name: install apache
|
||||
yum:
|
||||
name: httpd
|
||||
state: latest
|
||||
state: present
|
||||
|
||||
- name: conf httpd
|
||||
template:
|
||||
@@ -19,6 +20,7 @@
|
||||
service:
|
||||
name: httpd
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: open firewall port
|
||||
firewalld:
|
||||
@@ -26,15 +28,15 @@
|
||||
permanent: yes
|
||||
immediate: yes
|
||||
state: enabled
|
||||
ignore_errors: yes
|
||||
ignore_errors: true
|
||||
|
||||
- name: create documentroot
|
||||
file:
|
||||
name: /var/www/html/orsys.fr
|
||||
name: /var/www/html/example.org/
|
||||
state: directory
|
||||
|
||||
- name: create index file
|
||||
copy:
|
||||
src: index.html
|
||||
dest: /var/www/html/orsys.fr/index.html
|
||||
mode: 0644
|
||||
- name: copy index file
|
||||
template:
|
||||
src: index.txt
|
||||
dest: /var/www/html/example.org/index.html
|
||||
mode: 0644
|
||||
@@ -1 +0,0 @@
|
||||
<span style="text-align: center;background-color: #FD5401; font-size: 42px;">Hello World</span>
|
||||
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