diff --git a/mail.yaml b/mail.yaml index f7132f6..97a080d 100644 --- a/mail.yaml +++ b/mail.yaml @@ -8,6 +8,7 @@ - role: postfix ldap_server: "{{ hostvars['ldap'].ansible_host }}" fqdn_domain: "lilik.it" + lists_server: "{{ hostvars['lists'].ansible_host }}" - role: dovecot fqdn_domain: "lilik.it" ldap_server: "{{ hostvars['ldap'].ansible_host }}" diff --git a/roles/dovecot/tasks/main.yaml b/roles/dovecot/tasks/main.yaml index d2a2b6b..14af182 100644 --- a/roles/dovecot/tasks/main.yaml +++ b/roles/dovecot/tasks/main.yaml @@ -35,7 +35,7 @@ - blockinfile: dest: /etc/dovecot/conf.d/10-master.conf insertafter: 'inet_listener imaps {' - marker: '#ANSIBLE BLOCK FOR IMAPS PORT' + marker: '#{mark} ANSIBLE BLOCK FOR IMAPS PORT' block: | port = 993 ssl = yes @@ -44,7 +44,7 @@ - blockinfile: dest: "/etc/dovecot/conf.d/10-master.conf" insertafter: "unix_listener auth-userdb {" - marker: '#ANSIBLE BLOCK FOR AUTH USER' + marker: '#{mark} ANSIBLE BLOCK FOR AUTH USER' block: | group = postman mode = 0664 diff --git a/roles/postfix/tasks/main.yaml b/roles/postfix/tasks/main.yaml index e4b0f3d..4c63066 100644 --- a/roles/postfix/tasks/main.yaml +++ b/roles/postfix/tasks/main.yaml @@ -47,5 +47,27 @@ - lineinfile: dest=/etc/postfix/main.cf line="virtual_mailbox_maps = proxy:ldap:/etc/postfix/ldap-accounts.cf" notify: restart postfix -- lineinfile: dest=/etc/postfix/main.cf line="mydestination = mail.lilik.it, lists.lilik.it, localhost" regexp='mydestination =' state=present +- lineinfile: dest=/etc/postfix/main.cf line="mydestination = mail.lilik.it, localhost" regexp='mydestination =' state=present + notify: restart postfix + +- name: edit postfix mynetworks + lineinfile: dest=/etc/postfix/main.cf line="mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.0.0.0/16" regexp='mynetworks =' state=present + notify: restart postfix + +- name: create transport map + lineinfile: dest=/etc/postfix/transport line="lists.lilik.it :[{{ lists_server }}]" regexp="lists.lilik.it" create=yes + register: postfix_transport_result + notify: restart postfix + +- name: ensure transport map is compiled + shell: postmap /etc/postfix/transport + notify: reload postfix + when: postfix_transport_result | changed + +- name: enable transport map + lineinfile: dest=/etc/postfix/main.cf line="transport_maps = hash:/etc/postfix/transport" regexp='transport_maps =' state=present + notify: restart postfix + +- name: add lists.lilik.it relay + lineinfile: dest=/etc/postfix/main.cf line="relay_domains = lists.lilik.it" regexp='relay_domains =' state=present notify: restart postfix