From acd8e3da2a4be7f693b05d72294e1a963c87a29e Mon Sep 17 00:00:00 2001
From: shirenn <shirenn@crans.org>
Date: Wed, 10 Feb 2021 11:15:32 +0100
Subject: [PATCH] [nullmailer] PEPCRANSED BRO

---
 group_vars/all/nullmailer.yml   |  5 +++++
 plays/mail.yml                  | 13 +++----------
 roles/nullmailer/tasks/main.yml |  6 +++---
 3 files changed, 11 insertions(+), 13 deletions(-)
 create mode 100644 group_vars/all/nullmailer.yml

diff --git a/group_vars/all/nullmailer.yml b/group_vars/all/nullmailer.yml
new file mode 100644
index 00000000..5c63dbc4
--- /dev/null
+++ b/group_vars/all/nullmailer.yml
@@ -0,0 +1,5 @@
+---
+glob_nullmailer:
+  root: root@crans.org
+  smtp_server: smtp.adm.crans.org
+  defaulthost: crans.org
diff --git a/plays/mail.yml b/plays/mail.yml
index 536a2b68..38e1b298 100755
--- a/plays/mail.yml
+++ b/plays/mail.yml
@@ -1,14 +1,7 @@
 #!/usr/bin/env ansible-playbook
 ---
-# Redisdead is the main MX.
-# Soyouz and titanic are the old backup MX.
-# Boeing and sputnik are the new MX (still in installation ?).
-# All other servers uses nullmailer to send local mail to Crans SMTP.
-
-# Redirect local mail to mailserver
 - hosts: crans_server,!postfix
   vars:
-    mail_root: root@crans.org
-    mail_smtp_server: smtp.adm.crans.org
-    mail_defaulthost: crans.org
-  roles: ["nullmailer"]
+    nullmailer: "{{ glob_nullmailer | default({}) | combine(loc_nullmailer | default({})) }}"
+  roles:
+    - nullmailer
diff --git a/roles/nullmailer/tasks/main.yml b/roles/nullmailer/tasks/main.yml
index 21d2d875..2d354bba 100644
--- a/roles/nullmailer/tasks/main.yml
+++ b/roles/nullmailer/tasks/main.yml
@@ -11,18 +11,18 @@
 
 - name: Set nullmailer remotes
   copy:
-    content: "{{ mail_smtp_server }} smtp\n"
+    content: "{{ nullmailer.smtp_server }} smtp\n"
     dest: /etc/nullmailer/remotes
     mode: 0644
 
 - name: Set nullmailer adminaddr
   copy:
-    content: "{{ mail_root }}\n"
+    content: "{{ nullmailer.root }}\n"
     dest: /etc/nullmailer/adminaddr
     mode: 0644
 
 - name: Set nullmailer defaulthost
   copy:
-    content: "{{ mail_defaulthost }}\n"
+    content: "{{ nullmailer.defaulthost }}\n"
     dest: /etc/nullmailer/defaulthost
     mode: 0644
-- 
GitLab