12 Commits

Author SHA1 Message Date
bee4b6a526 correctly delete local ressources 2023-06-07 10:57:09 +02:00
e465a877cf switch to fqmn 2023-01-20 12:36:33 +01:00
895f1f15fd solution abr 2022-11-16 15:11:35 +01:00
4bd6eebafd wip 2022-11-16 14:41:55 +01:00
3cdcabd1ac wrong indent 2022-09-22 16:24:28 +02:00
071637a3f8 ajout https 2022-09-22 16:21:42 +02:00
37a75cef65 correct useless indent 2022-04-25 15:05:46 +02:00
b7a25b85b0 cleanup 2021-09-14 09:25:41 +02:00
c3e30f8e9f ok for centos8 2021-05-10 16:43:49 +02:00
e3e35d6dcd rajout install firewalld et dep 2021-04-19 17:10:04 +02:00
00a50bf543 add firewalld dep + block 2021-04-19 16:46:51 +02:00
20fc81cf83 branch solution 2021-03-16 21:07:11 +01:00
5 changed files with 50 additions and 126 deletions

View File

@@ -1,27 +1,6 @@
## Installer apache
# Playbook d'installation apache
**Prérequis**: index.txt et vhost.conf déployé sur cours.opendoor.fr
LEs fichiers vhost.conf et index.html sont récupérés par le pilote
**Tâche**: déployer un serveur apache à l'aide d'ansible
directement depuis le dépôt git
**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

View File

@@ -3,40 +3,72 @@
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
yum:
ansible.builtin.package:
name: httpd
state: present
- name: conf httpd
template:
src: vhost.conf
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
service:
ansible.builtin.service:
name: httpd
enabled: yes
state: started
- name: open firewall port
firewalld:
service: http
permanent: yes
immediate: yes
state: enabled
- 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
file:
ansible.builtin.file:
name: /var/www/html/example.org/
state: directory
- name: copy index file
template:
src: index.txt
- 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
mode: 0644
- name: delete temp ansible.builtin.files
ansible.builtin.file:
path: /tmp/sib_10
state: absent
delegate_to: localhost
become: false

View File

@@ -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

View File

@@ -1 +0,0 @@
<h1>hello World</h1>

View File

@@ -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>