initial commit
This commit is contained in:
BIN
10_premier_playbook.odt
Normal file
BIN
10_premier_playbook.odt
Normal file
Binary file not shown.
22
Readme.md
Normal file
22
Readme.md
Normal file
@@ -0,0 +1,22 @@
|
||||
1er playbook: installer apache
|
||||
-----
|
||||
|
||||
*Tâche*: déployer un serveur apache à l'aide d'ansible
|
||||
|
||||
*Condition*: déploiement d'un serveur apache
|
||||
|
||||
*Norme*: playbook et ansible-playbook
|
||||
|
||||
*Pratique*: Écrire le playbook permettant sur la machine **centos** uniquement:
|
||||
|
||||
1. récupère sur le pilote les fichiers https://cours.opendoor.fr/Fichiers/SIB/index.html et vhost.conf - le fichier index.txt sera renommé en index.html
|
||||
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
|
||||
63
apache.yml
Normal file
63
apache.yml
Normal file
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: install apache via ansible playbook
|
||||
hosts: centos
|
||||
|
||||
pre_tasks:
|
||||
- name: get ressources
|
||||
get_url:
|
||||
url: "{{ item }}"
|
||||
dest: /tmp
|
||||
loop:
|
||||
- https://cours.opendoor.fr/Fichiers/SIB/index.txt
|
||||
- https://cours.opendoor.fr/Fichiers/SIB/vhost.conf
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
|
||||
post_tasks:
|
||||
- name: cleanup
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- /tmp/index.txt
|
||||
- /tmp/vhost.conf
|
||||
become: false
|
||||
delegate_to: localhost
|
||||
|
||||
tasks:
|
||||
- name: install apache
|
||||
yum:
|
||||
name: httpd
|
||||
state: present
|
||||
|
||||
- name: conf httpd
|
||||
template:
|
||||
src: /tmp/vhost.conf
|
||||
dest: /etc/httpd/conf.d/vhost.conf
|
||||
mode: 0640
|
||||
owner: root
|
||||
group: apache
|
||||
|
||||
- name: activate apache
|
||||
service:
|
||||
name: httpd
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: open firewall port
|
||||
firewalld:
|
||||
service: http
|
||||
permanent: yes
|
||||
immediate: yes
|
||||
state: enabled
|
||||
|
||||
- name: create documentroot
|
||||
file:
|
||||
name: /var/www/html/{{ ansible_hostname }}
|
||||
state: directory
|
||||
|
||||
- name: copy index file
|
||||
template:
|
||||
src: /tmp/index.txt
|
||||
dest: /var/www/html/{{ ansible_hostname }}/index.html
|
||||
mode: 0644
|
||||
62
apache_trou.yml
Normal file
62
apache_trou.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
- 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