Compare commits
7 Commits
solution_a
...
master_abr
| Author | SHA1 | Date | |
|---|---|---|---|
| ab7d3b7efb | |||
| e0b0700715 | |||
| e24777f0a1 | |||
| e5c0153490 | |||
| 4b9729ef21 | |||
| 9bdef8791f | |||
| 78f641ccee |
30
Readme.md
30
Readme.md
@@ -1,6 +1,30 @@
|
|||||||
# Playbook d'installation apache
|
## Installer apache
|
||||||
|
|
||||||
LEs fichiers vhost.conf et index.html sont récupérés par le pilote
|
**Prérequis**: index.txt et vhost.conf déployé sur cours.opendoor.fr
|
||||||
|
|
||||||
directement depuis le dépôt git
|
**Tâche**: déployer un serveur apache à l'aide d'ansible
|
||||||
|
|
||||||
|
**Condition**: déploiement d'un serveur apache
|
||||||
|
|
||||||
|
**Norme**: playbook et ansible-playbook
|
||||||
|
|
||||||
|
**Préparation:**
|
||||||
|
|
||||||
|
- Récupèrez index.txt et vhost.conf sur le pilote
|
||||||
|
- Renommez le fichier index.txt sera renommé en index.html
|
||||||
|
|
||||||
|
**Pratique**: Écrire le playbook permettant sur la machine **centos** uniquement:
|
||||||
|
|
||||||
|
2. d'installer le serveur apache
|
||||||
|
3. d'ouvrir le parefeu
|
||||||
|
4. de créer le répertoire correspondant au documentRoot: /var/www/html/example.org
|
||||||
|
5. de déployer le fichier vhost.conf dans /etc/httpd/conf.d/
|
||||||
|
6. de déployer le fichier index.html dans le répertoire correspondant au documentRoot
|
||||||
|
7. d'activer le service
|
||||||
|
8. de lancer le service
|
||||||
|
|
||||||
|
**Validation**: on doit pouvoir se connecter en http sur la machine cible
|
||||||
|
|
||||||
|
|
||||||
|
Proposition de solution: voir la branche "solution"
|
||||||
|
|
||||||
|
|||||||
74
apache.yml
74
apache.yml
@@ -1,74 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache via ansible playbook
|
|
||||||
hosts: centos
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: retrieve ansible.builtin.files
|
|
||||||
ansible.builtin.git:
|
|
||||||
repo: https://infra.opendoor.fr/git/tom/sib_10_premier_playbook
|
|
||||||
dest: /tmp/sib_10
|
|
||||||
delegate_to: localhost
|
|
||||||
become: false
|
|
||||||
|
|
||||||
- name: install apache
|
|
||||||
ansible.builtin.package:
|
|
||||||
name: httpd
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: conf httpd
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: /tmp/sib_10/vhost.conf
|
|
||||||
dest: /etc/httpd/conf.d/vhost.conf
|
|
||||||
mode: 0640
|
|
||||||
owner: root
|
|
||||||
group: apache
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: httpd
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: setup firewall
|
|
||||||
block:
|
|
||||||
- name: install firewalld packages
|
|
||||||
ansible.builtin.package:
|
|
||||||
name:
|
|
||||||
- python3-firewall
|
|
||||||
- firewalld
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: enable firewalld service
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: firewalld
|
|
||||||
enabled: true
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: open firewall port
|
|
||||||
ansible.posix.firewalld:
|
|
||||||
service: "{{ item }}"
|
|
||||||
permanent: yes
|
|
||||||
immediate: yes
|
|
||||||
state: enabled
|
|
||||||
loop:
|
|
||||||
- http
|
|
||||||
- https
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
- name: create documentroot
|
|
||||||
ansible.builtin.file:
|
|
||||||
name: /var/www/html/example.org/
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: copy index ansible.builtin.file
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: /tmp/sib_10/index.txt
|
|
||||||
dest: /var/www/html/example.org/index.html
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: delete temp ansible.builtin.files
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /tmp/sib_10
|
|
||||||
state: absent
|
|
||||||
delegate_to: localhost
|
|
||||||
become: false
|
|
||||||
24
vhost.conf
Normal file
24
vhost.conf
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName example.org
|
||||||
|
ServerAlias www.example.org
|
||||||
|
ServerAlias {{ inventory_hostname }}
|
||||||
|
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/example.org>
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
<Directory /var/www/html/example.org/Private>
|
||||||
|
Options indexes
|
||||||
|
AuthName "stop"
|
||||||
|
AuthType Basic
|
||||||
|
AuthUserFile /etc/httpd/passwd
|
||||||
|
require valid-user
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
Reference in New Issue
Block a user