From 7ecf7be4a4360dbf08e29639d108e343c6b3e77c Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Wed, 14 Oct 2020 16:32:32 +0200 Subject: [PATCH] Do not remove line that would have a customized subject --- roles/base/tasks/mail.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/roles/base/tasks/mail.yml b/roles/base/tasks/mail.yml index 44e1fd8..2385473 100644 --- a/roles/base/tasks/mail.yml +++ b/roles/base/tasks/mail.yml @@ -1,4 +1,13 @@ --- +- name: Fetch rc.local content + command: "grep -v '^#' /etc/rc.local" + check_mode: false + register: rclocal_content + failed_when: false + changed_when: false + tags: + - misc + - name: Configure rc.local lineinfile: path: /etc/rc.local @@ -6,6 +15,8 @@ 'date | mail -s "boot/reboot of $(hostname -s)" {{ general_alert_email }}' insertbefore: 'echo' create: true + when: + - not (rclocal_content.stdout | regex_search('date \| mail -s (\"|\')boot/reboot of \$\(hostname -s\)')) tags: - misc