From f97317b76788f886764a564a9377fae88d7d5cc4 Mon Sep 17 00:00:00 2001 From: Jeremy Dubois Date: Thu, 8 Oct 2020 15:19:52 +0200 Subject: [PATCH] Better rc.local configuration Add line before the "echo '.'" line instead of the end Delete old entry not precising the hostname if still there --- roles/base/tasks/mail.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/base/tasks/mail.yml b/roles/base/tasks/mail.yml index dacd60d..44e1fd8 100644 --- a/roles/base/tasks/mail.yml +++ b/roles/base/tasks/mail.yml @@ -4,10 +4,20 @@ path: /etc/rc.local line: 'date | mail -s "boot/reboot of $(hostname -s)" {{ general_alert_email }}' + insertbefore: 'echo' create: true tags: - misc +- name: Delete rc.local entry of boot/reboot not precising hostname + lineinfile: + path: /etc/rc.local + regexp: + "^.* mail -s (?!.*of.*).+$" + state: absent + tags: + - misc + - name: Set root mail alias replace: dest: /etc/mail/aliases