]> arthur.barton.de Git - AnsibleRoles.git/commitdiff
postfix: Don't use Debconf to configure postfix
authorAlexander Barton <alex@barton.de>
Tue, 9 May 2017 13:06:31 +0000 (15:06 +0200)
committerAlexander Barton <alex@barton.de>
Tue, 9 May 2017 13:06:31 +0000 (15:06 +0200)
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
roles/postfix/tasks/main.yml

index 0469941c80acfe42ff0c292a1d4c23bf8338f5d1..081ea61cc84b38418658ab410a713edae3b957f0 100644 (file)
@@ -1,4 +1,6 @@
 ---
 # defaults file for postfix
 
+postfix_interfaces: "all"
 postfix_mailname: "{{ inventory_hostname }}"
+smtp_relay_host: ""
index 0dd6ec1a18b2da4e2f75fb5f49f7aadada49f8bb..039380c231520ec62da817e644b615813f7851d0 100644 (file)
@@ -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
   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