--- - 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