# 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


