ajout playboook syslog

This commit is contained in:
root 2023-10-15 19:24:15 +02:00
parent ceece5a13c
commit d86d83103d
2 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,45 @@
---
- name: syslog.yml
hosts: web
tasks:
- name: 1. installer rsyslog
apt:
name: rsyslog
state: latest
- name: ajout du serveur syslog distant
lineinfile:
path: /etc/rsyslog.conf
line: '*.* @172.20.10.4:514'
insertbefore: EOF
create: yes
notify:
- 5. redemarrer rsyslog
# - name: 3. Ajout de la ligne ForwardToSyslog
#shell: echo "ForwardToSyslog=yes" >> /etc/systemd/journald.conf
- name: 4. Decommente la ligne ForwardToSyslog
replace:
path: /etc/systemd/journald.conf
regexp: '^#ForwardToSyslog=yes'
replace: 'ForwardToSyslog=yes'
notify: 6. redemarrer journald.service
# notify:
#- restart rsyslog
#- name: redemarrage de syslog
#- restart journald.service
#- name: redemarrage de journald.service
handlers:
- name: 5. redemarrer rsyslog
service:
name: rsyslog
state: restarted
- name: 6. redemarrer journald.service
service:
name: systemd-journald.service
state: restarted

View File

@ -0,0 +1,52 @@
---
- name: syslog.yml
hosts: infra
tasks:
- name: 1. installer rsyslog
apt:
name: rsyslog
state: latest
- name: 2. decommente le chargement du module imudp dans rsyslog.conf
replace:
path: /etc/rsyslog.conf
regexp: '^#module\(load="imudp"\)'
replace: 'module(load="imudp")'
notify:
- 5. redemarrer rsyslog
- name: 3. decommente le chargement du module imudp port 514 dans rsyslog.conf
replace:
path: /etc/rsyslog.conf
regexp: '^#input\(type="imudp" port="514"\)'
replace: 'input(type="imudp" port="514")'
notify:
- 5. redemarrer rsyslog
# - name: 3. Ajout de la ligne ForwardToSyslog
#shell: echo "ForwardToSyslog=yes" >> /etc/systemd/journald.conf
- name: 4. Decommente la ligne ForwardToSyslog
replace:
path: /etc/systemd/journald.conf
regexp: '^#ForwardToSyslog=yes'
replace: 'ForwardToSyslog=yes'
notify: 6. redemarrer journald.service
# notify:
#- restart rsyslog
#- name: redemarrage de syslog
#- restart journald.service
#- name: redemarrage de journald.service
handlers:
- name: 5. redemarrer rsyslog
service:
name: rsyslog
state: restarted
- name: 6. redemarrer journald.service
service:
name: systemd-journald.service
state: restarted