From c5e8cf8b5ba2a8199050e33050b6445093d63ace Mon Sep 17 00:00:00 2001 From: Guillaume Emorine Date: Fri, 11 Oct 2024 11:38:18 +0200 Subject: [PATCH] Ajout de certains fichiers du TP Ansible (Jusqu'au proxy). --- bts_annee_2/sisr2/README.md | 2 +- bts_annee_2/sisr2/ansible/README.md | 2 ++ bts_annee_2/sisr2/ansible/hosts | 6 ++++ bts_annee_2/sisr2/ansible/squid.yml | 32 ++++++++++++++++++++++ bts_annee_2/sisr2/ansible/syslog-cli.yml | 35 ++++++++++++++++++++++++ bts_annee_2/sisr2/ansible/syslog.yml | 30 ++++++++++++++++++++ bts_annee_2/sisr2/ansible/web.yml | 21 ++++++++++++++ 7 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 bts_annee_2/sisr2/ansible/README.md create mode 100644 bts_annee_2/sisr2/ansible/hosts create mode 100644 bts_annee_2/sisr2/ansible/squid.yml create mode 100644 bts_annee_2/sisr2/ansible/syslog-cli.yml create mode 100644 bts_annee_2/sisr2/ansible/syslog.yml create mode 100644 bts_annee_2/sisr2/ansible/web.yml diff --git a/bts_annee_2/sisr2/README.md b/bts_annee_2/sisr2/README.md index 1b731e6..6a1fcbd 100644 --- a/bts_annee_2/sisr2/README.md +++ b/bts_annee_2/sisr2/README.md @@ -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é. diff --git a/bts_annee_2/sisr2/ansible/README.md b/bts_annee_2/sisr2/ansible/README.md new file mode 100644 index 0000000..3e283f5 --- /dev/null +++ b/bts_annee_2/sisr2/ansible/README.md @@ -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. diff --git a/bts_annee_2/sisr2/ansible/hosts b/bts_annee_2/sisr2/ansible/hosts new file mode 100644 index 0000000..ce091d1 --- /dev/null +++ b/bts_annee_2/sisr2/ansible/hosts @@ -0,0 +1,6 @@ +[adm] +infra + +[web] +web1 +web2 diff --git a/bts_annee_2/sisr2/ansible/squid.yml b/bts_annee_2/sisr2/ansible/squid.yml new file mode 100644 index 0000000..dd66ace --- /dev/null +++ b/bts_annee_2/sisr2/ansible/squid.yml @@ -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 diff --git a/bts_annee_2/sisr2/ansible/syslog-cli.yml b/bts_annee_2/sisr2/ansible/syslog-cli.yml new file mode 100644 index 0000000..6fd4228 --- /dev/null +++ b/bts_annee_2/sisr2/ansible/syslog-cli.yml @@ -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 + + diff --git a/bts_annee_2/sisr2/ansible/syslog.yml b/bts_annee_2/sisr2/ansible/syslog.yml new file mode 100644 index 0000000..46cef9d --- /dev/null +++ b/bts_annee_2/sisr2/ansible/syslog.yml @@ -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 + + diff --git a/bts_annee_2/sisr2/ansible/web.yml b/bts_annee_2/sisr2/ansible/web.yml new file mode 100644 index 0000000..62d8f4d --- /dev/null +++ b/bts_annee_2/sisr2/ansible/web.yml @@ -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 -- 2.47.2