--- - hosts: web name: syslog-client-configure tasks: - name: editing journald.conf... ansible.builtin.replace: path: /etc/systemd/journald.conf regexp: '^#ForwardToSyslog=yes' replace: 'ForwardToSyslog=yes' backup: yes notify: restart journald - name: editing rsyslog.conf... ansible.builtin.lineinfile: path: /etc/rsyslog.conf line: '*.* @192.168.0.48:514' create: yes notify: restart rsyslog handlers: - name: restart journald service: name: systemd-journald state: restarted - name: restart rsyslog service: name: rsyslog state: restarted