Ajout de fichiers de TP d'Ansible. #36

Merged
guillaume.emorine merged 3 commits from test into main 2024-10-11 11:42:27 +02:00
7 changed files with 127 additions and 1 deletions

View File

@ -1,2 +1,2 @@
Dépôt de seconde année de SISR. Dépôt de seconde année de SISR.
Chaque dossier porte le numéro de la séance associée. Chaque dossier porte le nom du sujet associé.

View File

@ -0,0 +1,2 @@
Fichier hosts utilisé pour ansible lors du TP de la séance 16.
Sont inclus les fichiers idempotents .yml d'ansible que j'ai fait.

View File

@ -0,0 +1,6 @@
[adm]
infra
[web]
web1
web2

View File

@ -0,0 +1,32 @@
# squid.yml
---
- hosts: adm
vars:
- proxy_port: 8080
- proxy_mem: 128
- proxy_localnet: "192.168.0.0/24"
tasks:
- name: 1. Installe le proxy Squid sur la machine Infra.
apt:
name: squid
state: present
# Uncomment this on FIRST RUN, comment afterwards !
# - name: 2. Récupère le fichier squid.conf.
# ansible.builtin.fetch:
# src: /etc/squid/squid.conf
# dest: squid.conf.j2
# flat: yes
- name: 3. Envoie squid.conf
template:
src: squid.conf.j2
dest: /etc/squid/squid.conf
notify: Restart squid
handlers:
- name: Restart squid
service:
name: squid
state: restarted

View File

@ -0,0 +1,35 @@
# syslog-cli.yml
---
- hosts: web
tasks:
- name: 1. Installe le paquet rsyslog.
apt:
name: rsyslog
state: present
- name: 2. Ajoute la ligne pour forwarder les logs rsyslog au bon endroit.
lineinfile:
path: /etc/rsyslog.conf
line: '*.* @192.168.0.37:514'
create: yes
notify: Restart rsyslog
- name: 3. Forward les logs journald vers syslog.
replace:
path: /etc/systemd/journald.conf
regexp: '^#ForwardToSyslog=yes'
replace: 'ForwardToSyslog=yes'
notify: Restart journald
handlers:
- name: Restart rsyslog
service:
name: rsyslog
state: restarted
- name: Restart journald
service:
name: systemd-journald
state: restarted

View File

@ -0,0 +1,30 @@
# syslog.yml
---
- hosts: adm
tasks:
- name: 1. Installe le paquet rsyslog.
apt:
name: rsyslog
state: present
- name: 2. Active le module UDP sur le serveur syslog.
replace:
path: /etc/rsyslog.conf
regexp: '^#module\(load="imudp"\)'
replace: 'module(load="imudp")'
notify: Restart rsyslog
- name: 3. Active l'écoute sur le port UDP 514.
replace:
path: /etc/rsyslog.conf
regexp: '^#input\(type="imudp" port="514"\)'
replace: 'input(type="imudp" port="514")'
notify: Restart rsyslog
handlers:
- name: Restart rsyslog
service:
name: rsyslog
state: restarted

View File

@ -0,0 +1,21 @@
# playbook.yml
---
- hosts: web
tasks:
- name: 1. installe Apache
apt:
name: apache2
state: present
- name: 2. installe PHP pour Apache
apt:
name: php
state: present
- name: 3. installe php-mbstring
apt:
name: php-mbstring
state: present
- name: 4. installe index.html
copy:
src: index.html
dest: /var/www/html/index.html
mode: 0664