From 7bb27acd2c900a3bccaf33ecf5e4783743186478 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 11 Aug 2025 14:07:45 +0200 Subject: [PATCH] opensmtpd: configure root mail alias And add a README. --- roles/opensmtpd/README.md | 3 +++ roles/opensmtpd/tasks/main.yml | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 roles/opensmtpd/README.md diff --git a/roles/opensmtpd/README.md b/roles/opensmtpd/README.md new file mode 100644 index 0000000..5f28b4c --- /dev/null +++ b/roles/opensmtpd/README.md @@ -0,0 +1,3 @@ +Install opensmtpd and configure it for sending local mail through a relay. + +The NetBox configuration context must define `mail_relay` with the relay hostname and `mail_root` with the email address where mail for root should be forwarded. diff --git a/roles/opensmtpd/tasks/main.yml b/roles/opensmtpd/tasks/main.yml index d4be6fe..13cc8ba 100644 --- a/roles/opensmtpd/tasks/main.yml +++ b/roles/opensmtpd/tasks/main.yml @@ -27,6 +27,12 @@ follow: true notify: restart smtpd +- name: Configure root mail alias + lineinfile: + path: /etc/smtpd/aliases + regexp: "^#? *root:" + line: "root: {{ mail_root }}" + - name: Enable mail server service: name: "{% if ansible_os_family == 'Alpine' %}smtpd{% else %}opensmtpd{% endif %}"