From 7e8118ca9f171716a82915bd10cf0ea475bf3b5a Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Tue, 9 May 2017 15:06:31 +0200 Subject: [PATCH] postfix: Don't use Debconf to configure postfix Ansible is used to configure the Postfix mail system, so set Debconf to "No configuration" but add some more options to this role: - postfix_interfaces (defauult: "all") - smtp_relay_host (default: none) --- roles/postfix/defaults/main.yml | 2 ++ roles/postfix/tasks/main.yml | 55 +++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/roles/postfix/defaults/main.yml b/roles/postfix/defaults/main.yml index 0469941..081ea61 100644 --- a/roles/postfix/defaults/main.yml +++ b/roles/postfix/defaults/main.yml @@ -1,4 +1,6 @@ --- # defaults file for postfix +postfix_interfaces: "all" postfix_mailname: "{{ inventory_hostname }}" +smtp_relay_host: "" diff --git a/roles/postfix/tasks/main.yml b/roles/postfix/tasks/main.yml index 0dd6ec1..039380c 100644 --- a/roles/postfix/tasks/main.yml +++ b/roles/postfix/tasks/main.yml @@ -1,26 +1,16 @@ --- # postfix tasks -- name: configure Postfix "mailname" +# Set Debconf to not configure Postfix at all: +- name: configure debconf(1) to not configure Postfix tags: + - debconf - mail - - packages - - postfix - debconf: > - name=postfix - question=postfix/mailname - value="{{ postfix_mailname }}" - vtype=select - -- name: configure Postfix "destinations" - tags: - - mail - - packages - postfix debconf: > name=postfix - question=postfix/destinations - value="{{ postfix_mailname }}, $myhostname, localhost.$mydomain, localhost" + question=postfix/main_mailer_type + value="No configuration" vtype=select - name: install "postfix" package @@ -66,13 +56,46 @@ lineinfile: > dest=/etc/postfix/main.cf group=root - line="myhostname = {{ inventory_hostname }}" + line="myhostname = {{ postfix_mailname }}" mode=0644 owner=root regexp="^myhostname" notify: - restart "postfix" +- name: set Posfix "mydestination" + tags: + - mail + - postfix + lineinfile: > + dest=/etc/postfix/main.cf + line="mydestination = {{ postfix_mailname }}, localhost" + regexp="^mydestination" + notify: + - restart "postfix" + +- name: set Posfix "inet_interfaces" + tags: + - mail + - postfix + lineinfile: > + dest=/etc/postfix/main.cf + line="inet_interfaces = {{ postfix_interfaces }}" + regexp="^inet_interfaces" + notify: + - restart "postfix" + +- name: set Posfix "relayhost" + tags: + - mail + - postfix + lineinfile: > + dest=/etc/postfix/main.cf + line="relayhost = {{ smtp_relay_host }}" + regexp="^relayhost" + notify: + - restart "postfix" + - name: ensure service "postfix" is enabled and started tags: - mail -- 2.39.2