Compare commits
10 Commits
master_abr
...
solution
| Author | SHA1 | Date | |
|---|---|---|---|
| c4294b55a6 | |||
| c92c54ff3b | |||
| 3cdcabd1ac | |||
| 071637a3f8 | |||
| 37a75cef65 | |||
| b7a25b85b0 | |||
| c3e30f8e9f | |||
| e3e35d6dcd | |||
| 00a50bf543 | |||
| 20fc81cf83 |
27
Readme.md
27
Readme.md
@@ -1,27 +0,0 @@
|
|||||||
## Installer apache
|
|
||||||
|
|
||||||
**Prérequis**: index.txt et vhost.conf déployé sur cours.opendoor.fr
|
|
||||||
|
|
||||||
**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 sur le pilote les fichiers https://cours.opendoor.fr/Fichiers/SIB/index.html et vhost.conf
|
|
||||||
- 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
|
|
||||||
5. de déployer le fichier /srv/vhost.conf dans /etc/httpd/conf.d/
|
|
||||||
6. de déployer le fichier /srv/index.html dans le répertoire correspondant au documentRoot
|
|
||||||
7. d'activer le service
|
|
||||||
8. de lancer le service
|
|
||||||
9. de supprimer les fichiers à l'étape #1
|
|
||||||
|
|
||||||
**Validation**: on doit pouvoir se connecter en http sur la machine cible
|
|
||||||
27
apache.yml
27
apache.yml
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: install apache
|
- name: install apache
|
||||||
yum:
|
ansible.builtin.package:
|
||||||
name: httpd
|
name: httpd
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- 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
|
||||||
@@ -17,26 +17,37 @@
|
|||||||
group: apache
|
group: apache
|
||||||
|
|
||||||
- name: activate apache
|
- name: activate apache
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: httpd
|
name: httpd
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
|
- name: setup firewall
|
||||||
|
block:
|
||||||
|
- name: install firewalld packages
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- python3-firewall
|
||||||
|
- firewalld
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: open firewall port
|
- name: open firewall port
|
||||||
firewalld:
|
ansible.posix.firewalld:
|
||||||
service: http
|
service: "{{ item }}"
|
||||||
permanent: yes
|
permanent: yes
|
||||||
immediate: yes
|
immediate: yes
|
||||||
state: enabled
|
state: enabled
|
||||||
ignore_errors: true
|
loop:
|
||||||
|
- http
|
||||||
|
- https
|
||||||
|
|
||||||
- name: create documentroot
|
- name: create documentroot
|
||||||
file:
|
ansible.builtin.file:
|
||||||
name: /var/www/html/example.org/
|
name: /var/www/html/example.org/
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: copy index file
|
- name: copy index file
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: index.txt
|
src: index.txt
|
||||||
dest: /var/www/html/example.org/index.html
|
dest: /var/www/html/example.org/index.html
|
||||||
mode: 0644
|
mode: 0644
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
---
|
|
||||||
- name: install apache via ansible playbook
|
|
||||||
CHANGEME: centos
|
|
||||||
|
|
||||||
pre_tasks:
|
|
||||||
- name: get ressources
|
|
||||||
CHANGEME:
|
|
||||||
url: "{{ item }}"
|
|
||||||
dest: /tmp
|
|
||||||
loop:
|
|
||||||
- https://cours.opendoor.fr/Fichiers/SIB/index.txt
|
|
||||||
- https://cours.opendoor.fr/Fichiers/SIB/vhost.conf
|
|
||||||
CHANGEME: localhost
|
|
||||||
become: false
|
|
||||||
|
|
||||||
CHANGEME_tasks:
|
|
||||||
- name: cleanup
|
|
||||||
file:
|
|
||||||
path: "{{ item }}"
|
|
||||||
state: absent
|
|
||||||
CHANGEME:
|
|
||||||
- /tmp/index.txt
|
|
||||||
- /tmp/vhost.conf
|
|
||||||
CHANGEME: false
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
- name: install apache
|
|
||||||
CHANGEME:
|
|
||||||
name: httpd
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: conf httpd
|
|
||||||
CHANGEME:
|
|
||||||
CHANGEME: /tmp/vhost.conf
|
|
||||||
CHANGEME: /etc/httpd/conf.d/vhost.conf
|
|
||||||
mode: 0640
|
|
||||||
owner: root
|
|
||||||
group: apache
|
|
||||||
|
|
||||||
- name: activate apache
|
|
||||||
CHANGEME:
|
|
||||||
name: httpd
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
|
|
||||||
- name: open firewall port
|
|
||||||
firewalld:
|
|
||||||
CHANGEME: http
|
|
||||||
permanent: yes
|
|
||||||
immediate: yes
|
|
||||||
state: enabled
|
|
||||||
|
|
||||||
- name: create documentroot
|
|
||||||
CHANGEME:
|
|
||||||
name: /var/www/html/orsys.fr
|
|
||||||
state: CHANGEME
|
|
||||||
|
|
||||||
- name: copy index file
|
|
||||||
CHANGEME:
|
|
||||||
src: /tmp/index.txt
|
|
||||||
CHANGEMEdest: /var/www/html/orsys.fr/index.html
|
|
||||||
mode: 0644
|
|
||||||
Reference in New Issue
Block a user