From 55fae33c5969994a245724fb40d5164bc1f849c4 Mon Sep 17 00:00:00 2001
From: Hinrikus Wolf <mail@hinrikus-wolf.de>
Date: Sun, 11 Feb 2018 15:54:53 +0100
Subject: [PATCH] postfix: add memcached support for postscreen

---
 postfix/tasks/main.yml                |  6 ++++--
 postfix/templates/main.cf.j2          |  2 ++
 postfix/templates/postscreen_cache.j2 | 12 ++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 postfix/templates/postscreen_cache.j2

diff --git a/postfix/tasks/main.yml b/postfix/tasks/main.yml
index fad51fa..b50ddd8 100644
--- a/postfix/tasks/main.yml
+++ b/postfix/tasks/main.yml
@@ -6,6 +6,7 @@
     - postfix
     - postfix-pcre
     - postfix-cdb
+    - memcached
   tags: 
     - postfix
     - mail
@@ -24,9 +25,10 @@
     - mail
 
 - name: ensure templated config is present
-  template: src=templates/{{ item }} dest=/etc/postfix/main.cf
+  template: src=templates/{{ item }}.j2 dest=/etc/postfix/{{ item }}
   with_items:
-    - main.cf.j2
+    - main.cf
+    - postscreen_cache
   notify: 
     - restart postfix
   tags:
diff --git a/postfix/templates/main.cf.j2 b/postfix/templates/main.cf.j2
index a3e5995..f21ff9f 100644
--- a/postfix/templates/main.cf.j2
+++ b/postfix/templates/main.cf.j2
@@ -115,3 +115,5 @@ postscreen_bare_newline_enable = yes
 # default: postscreen_bare_newline_action = ignore
 postscreen_bare_newline_action = drop
 #
+postscreen_cache_map = memcache:/etc/postfix/postscreen_cache
+proxy_write_maps = proxy:btree:/var/lib/postfix/postscreen_cache 
diff --git a/postfix/templates/postscreen_cache.j2 b/postfix/templates/postscreen_cache.j2
new file mode 100644
index 0000000..0a886f8
--- /dev/null
+++ b/postfix/templates/postscreen_cache.j2
@@ -0,0 +1,12 @@
+# Django : 2014-11-07 postscreen-cache Konfigurationsdatei
+# #
+#
+
+{% for partner in groups['mail'] %}
+  {% if partner != ansible_hostname %}
+memcache = inet::{{hostvars[partner]["tinc_vpnip"]}}11211
+  {% endif %}
+{% endfor %}
+
+backup = proxy:btree:/var/lib/postfix/postscreen_cache
+key_format = postscreen:%s
-- 
GitLab