From 223ace4a4ae63ff08183629f98390b52f5057495 Mon Sep 17 00:00:00 2001
From: Chris Coley <chris@codingallnight.com>
Date: Sat, 11 May 2019 03:27:55 -0700
Subject: [PATCH] Always generate lookup tables, even if they're empty

If we don't generate tables even when they're going to be empty, then we have to
figure out how to remove the 'transport_maps' and 'smtp_sasl_password_maps'
config lines that point at them. Postfix is fine with empty tables, so this is
the simplest way to solve the problem of undefined lookup mappings.

The alternative is to set the 'transport_maps' and 'smtp_sasl_password_maps'
properties to nothing, which Postfix is also fine with, or remove them entirely.
---
 tasks/main.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tasks/main.yml b/tasks/main.yml
index 67be48a..d7c8d2e 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -30,7 +30,6 @@
     mode: 0644
 
 - name: Create the SASL password lookup table
-  when: postfix__tables.sasl_passwd is defined and postfix__tables.sasl_passwd
   template:
     src: lookup_table.j2
     dest: /etc/postfix/sasl_passwd.in
@@ -38,11 +37,10 @@
     group: root
     mode: 0600
   vars:
-    table: '{{ postfix__tables.sasl_passwd }}'
+    table: '{{ postfix__tables.sasl_passwd | default({}) }}'
   notify: ['make postfix sasl_passwd.db']
 
 - name: Create the transport lookup table
-  when: postfix__tables.transport is defined and postfix__tables.transport
   template:
     src: lookup_table.j2
     dest: /etc/postfix/transport.in
@@ -50,7 +48,7 @@
     group: root
     mode: 0644
   vars:
-    table: '{{ postfix__tables.transport }}'
+    table: '{{ postfix__tables.transport | default({}) }}'
   notify: ['make postfix transport.db']
 
 - name: Mark the 'main.cf' file as being managed by Ansible
-- 
GitLab