Compare commits
12 Commits
master
...
solution_a
| Author | SHA1 | Date | |
|---|---|---|---|
| bee4b6a526 | |||
| e465a877cf | |||
| 895f1f15fd | |||
| 4bd6eebafd | |||
| 3cdcabd1ac | |||
| 071637a3f8 | |||
| 37a75cef65 | |||
| b7a25b85b0 | |||
| c3e30f8e9f | |||
| e3e35d6dcd | |||
| 00a50bf543 | |||
| 20fc81cf83 |
27
Readme.md
27
Readme.md
@@ -1,27 +1,6 @@
|
||||
## Installer apache
|
||||
# Playbook d'installation apache
|
||||
|
||||
**Tâche**: déployer un serveur apache à l'aide d'ansible
|
||||
LEs fichiers vhost.conf et index.html sont récupérés par le pilote
|
||||
|
||||
**Condition**: déploiement d'un serveur apache
|
||||
|
||||
**Norme**: playbook et ansible-playbook
|
||||
|
||||
**Préparation:**
|
||||
|
||||
- Faites un git clone de l'atelier afin de disposer des fichiers index.txt et vhost.conf
|
||||
|
||||
**Pratique**: Écrire le playbook permettant sur la machine **centos** uniquement:
|
||||
|
||||
1. d'installer le serveur apache
|
||||
4. 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"
|
||||
directement depuis le dépôt git
|
||||
|
||||
|
||||
74
apache.yml
Normal file
74
apache.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
- 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
24
vhost.conf
@@ -1,24 +0,0 @@
|
||||
<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