From e15c91e45ddf019c998b0145a3c61bec5fef0abc Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Tue, 9 Jul 2024 21:52:55 +0000 Subject: [PATCH] Check for rsyslog.conf, update to regex --- tasks/main.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 902ee13..b45db64 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,9 +1,18 @@ --- -- name: Disable kernel logging - lineinfile: +- name: Check if /etc/rsyslogd.conf exists + ansible.builtin.stat: path: /etc/rsyslog.conf - regexp: '^\s+#?(.*imklog.)$' + register: rsyslogd_conf + + +- name: Disable kernel logging + ansible.builtin.lineinfile: + path: /etc/rsyslog.conf + regexp: '^[\s#]*(.*imklog.*)$' line: '#\1' + backrefs: true backup: yes + when: rsyslogd_conf.stat.exists notify: Restart Rsyslog +