Changeset - 107417b217e0
[Not reviewed]
0 3 3
Branko Majic (branko) - 9 years ago 2015-04-07 23:00:42
branko@majic.rs
MAR-4: Added some missing service restarts for Postfix. Added deployment of Dovecot configuration.
6 files changed with 103 insertions and 3 deletions:
0 comments (0 inline, 0 general)
roles/mail_server/files/main.cf
Show inline comments
 
@@ -42,4 +42,8 @@ inet_interfaces = all
 
# LDAP directory look-ups for domains, mailboxes and aliases.
 
virtual_mailbox_domains=ldap:/etc/postfix/ldap-virtual-mailbox-domains.cf
 
virtual_mailbox_maps=ldap:/etc/postfix/ldap-virtual-mailbox-maps.cf
 
virtual_alias_maps=ldap:/etc/postfix/ldap-virtual-alias-maps.cf
 
\ No newline at end of file
 
virtual_alias_maps=ldap:/etc/postfix/ldap-virtual-alias-maps.cf
 

	
 
# Delivery of mails via Dovecot for virtual domains.
 
virtual_transport=dovecot
 
dovecot_destination_recipient_limit=1
 
\ No newline at end of file
roles/mail_server/handlers/main.yml
Show inline comments
 
---
 

	
 
- name: Purge Exim configuration
 
  apt: name="exim4*" state=absent purge=yes
 
\ No newline at end of file
 
  apt: name="exim4*" state=absent purge=yes
 

	
 
- name: Restart Postfix
 
  service: name="postfix" state=restarted
 

	
 
- name: Restart Dovecot
 
  service: name="dovecot" state=restarted
 
\ No newline at end of file
roles/mail_server/tasks/main.yml
Show inline comments
 
@@ -22,15 +22,23 @@
 
- name: Install SWAKS
 
  apt: name="swaks" state=installed
 

	
 
- name: Copy the LDAP TLS truststore into Postfix chroot
 
  file: dest="/var/spool/postfix/etc/ssl/certs/truststore.pem" src="/etc/ssl/certs/truststore.pem"
 
        mode=644 owner=root group=root state=file
 

	
 
- name: Deploy Postfix configurations files for LDAP look-ups
 
  template: src="{{ item }}.cf.j2" dest="/etc/postfix/{{ item }}.cf" owner=root group=postfix mode=640
 
  with_items:
 
    - ldap-virtual-alias-maps
 
    - ldap-virtual-mailbox-domains
 
    - ldap-virtual-mailbox-maps
 
  notify:
 
    - Restart Postfix
 

	
 
- name: Deploy Postfix main configurationg
 
- name: Deploy Postfix main configuration
 
  copy: src="main.cf" dest="/etc/postfix/main.cf"
 
  notify:
 
    - Restart Postfix
 

	
 
- name: Create mail owner group
 
  group: name="{{ mail_user.name }}" gid="{{ mail_user.gid }}" state=present
 
@@ -38,3 +46,31 @@
 
- name: Create mail owner user
 
  user: name="{{ mail_user.name }}" uid="{{ mail_user.uid }}" group="{{ mail_user.name }}"
 
        home="/var/{{ mail_user.name }}" state=present
 

	
 
- name: Disable Dovecot system authentication
 
  lineinfile: dest="/etc/dovecot/conf.d/10-auth.conf" line="!include auth-system.conf.ext" state=absent
 
  notify:
 
    - Restart Dovecot
 

	
 
- name: Deploy Dovecot configuration file with overrides
 
  template: src="99-local.conf.j2" dest="/etc/dovecot/conf.d/99-local.conf" owner=root group=root mode=644
 
  notify:
 
    - Restart Dovecot
 

	
 
- name: Deploy Dovecot configuration file for LDAP look-ups
 
  template: src="dovecot-ldap.conf.ext.j2" dest="/etc/dovecot/dovecot-ldap.conf.ext" owner=root group=root mode=600
 
  notify:
 
    - Restart Dovecot
 

	
 
- name: Configure Postfix for Dovecot delivery
 
  lineinfile: dest=/etc/postfix/master.cf state=present
 
              regexp="dovecot"
 
              line="dovecot   unix  -       n       n       -       -       pipe    flags=DRhu user={{ mail_user.name }}:{{ mail_user.name }} argv=/usr/lib/dovecot/dovecot-lda -f ${sender} -d ${recipient}"
 
  notify:
 
    - Restart Postfix
 

	
 
- name: Enable Postfix service
 
  service: name=postfix enabled=yes state=started
 

	
 
- name: Enable Dovecot service
 
  service: name=dovecot enabled=yes state=started
roles/mail_server/templates/99-local.conf
Show inline comments
 
new file 100644
roles/mail_server/templates/99-local.conf.j2
Show inline comments
 
new file 100644
 
# Authentication configuration.
 
auth_mechanisms = plain login
 

	
 
passdb {
 
  driver = ldap
 
  args = /etc/dovecot/dovecot-ldap.conf.ext
 
}
 

	
 
userdb {
 
  driver = ldap
 
  args = /etc/dovecot/dovecot-ldap.conf.ext
 
  default_fields = uid={{ mail_user.name }} gid={{ mail_user.name }} home=/var/{{ mail_user.name}}/%d/%n
 
}
 

	
 
# Mail storage configuration.
 
mail_location = maildir:/var/{{ mail_user.name}}/%d/%n/Maildir
 
# This is used for old workaround.org installations.
 
#separator = .
 

	
 
# Communication with other services.
 
service auth {
 
  unix_listener /var/spool/postfix/private/auth {
 
    mode = 0660
 
    user = postfix
 
    group = postfix
 
  }
 
}
 

	
 
# TLS configuration.
 
ssl_cert = <{{ imap_tls_certificate }}
 
ssl_key = <{{ imap_tls_key }}
 
ssl = required
 

	
 
# Mail delivery.
 
protocol lda {
 
  mail_plugins = $mail_plugins sieve
 
  postmaster_address = postmaster@example.com
 
}
roles/mail_server/templates/dovecot-ldap.conf.ext.j2
Show inline comments
 
new file 100644
 
uris = {{ mail_ldap.url }}
 
dn = cn=dovecot,ou=services,{{ mail_ldap.root_dn }}
 
dnpass = {{ mail_ldap.dovecot_password }}
 
tls = yes
 
tls_ca_cert_file = {{ mail_ldap.tls_truststore }}
 
tls_require_cert = demand
 
auth_bind = yes
 
base = ou=people,{{ mail_ldap.root_dn }}
 
scope = onelevel
 
user_filter = (&(objectClass=inetOrgPerson)(mail=%u)(memberOf=cn=mail,ou=groups,{{ mail_ldap.root_dn }}))
 
pass_attrs = mail=user,userPassword=password
 
pass_filter = (&(objectClass=inetOrgPerson)(mail=%u)(memberOf=cn=mail,ou=groups,{{ mail_ldap.root_dn }}))
 
iterate_attrs = mail=user
 
iterate_filter = (memberOf=cn=mail,ou=groups,{{ mail_ldap.root_dn }})
 
default_pass_scheme = SSHA
 
user_attrs =
0 comments (0 inline, 0 general)