Merge pull request 'Ajout de fichiers de TP d'Ansible.' (#36) from test into main
Reviewed-on: #36
This commit is contained in:
commit
1fb8100c32
@ -1,2 +1,2 @@
|
||||
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é.
|
||||
|
2
bts_annee_2/sisr2/ansible/README.md
Normal file
2
bts_annee_2/sisr2/ansible/README.md
Normal 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.
|
6
bts_annee_2/sisr2/ansible/hosts
Normal file
6
bts_annee_2/sisr2/ansible/hosts
Normal file
@ -0,0 +1,6 @@
|
||||
[adm]
|
||||
infra
|
||||
|
||||
[web]
|
||||
web1
|
||||
web2
|
32
bts_annee_2/sisr2/ansible/squid.yml
Normal file
32
bts_annee_2/sisr2/ansible/squid.yml
Normal 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
|
35
bts_annee_2/sisr2/ansible/syslog-cli.yml
Normal file
35
bts_annee_2/sisr2/ansible/syslog-cli.yml
Normal 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
|
||||
|
||||
|
30
bts_annee_2/sisr2/ansible/syslog.yml
Normal file
30
bts_annee_2/sisr2/ansible/syslog.yml
Normal 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
|
||||
|
||||
|
21
bts_annee_2/sisr2/ansible/web.yml
Normal file
21
bts_annee_2/sisr2/ansible/web.yml
Normal 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
|
Loading…
x
Reference in New Issue
Block a user