diff --git a/mail_server.yaml b/mail.yaml similarity index 64% rename from mail_server.yaml rename to mail.yaml index 8cce310..f7132f6 100644 --- a/mail_server.yaml +++ b/mail.yaml @@ -8,3 +8,6 @@ - role: postfix ldap_server: "{{ hostvars['ldap'].ansible_host }}" fqdn_domain: "lilik.it" + - role: dovecot + fqdn_domain: "lilik.it" + ldap_server: "{{ hostvars['ldap'].ansible_host }}" diff --git a/roles/dovecot/handlers/main.yml b/roles/dovecot/handlers/main.yml new file mode 100644 index 0000000..0a4ff65 --- /dev/null +++ b/roles/dovecot/handlers/main.yml @@ -0,0 +1,8 @@ +--- +- include: service.yaml + vars: + service_name: postfix + +- include: service.yaml + vars: + service_name: dovecot diff --git a/roles/dovecot/tasks/main.yaml b/roles/dovecot/tasks/main.yaml new file mode 100644 index 0000000..d2a2b6b --- /dev/null +++ b/roles/dovecot/tasks/main.yaml @@ -0,0 +1,121 @@ +- include: service.yaml + # static: yes # see static include issue: https://github.com/ansible/ansible/issues/13485 + vars: + service_name: dovecot + service_packages: + - dovecot-ldap + - dovecot-imapd + - rsyslog +# - dovecot-lmtpd +# - amavisd-new +# - postgrey #TODO +# - spamassassin +# - clamav-daemon + +- lineinfile: dest=/etc/postfix/main.cf line="virtual_transport = dovecot" state=present + notify: restart postfix + +- blockinfile: + dest: /etc/postfix/master.cf + block: | + dovecot unix - n n - - pipe + flags=DRhu user=postman:postman argv=/usr/lib/dovecot/deliver -d ${recipient} -f ${sender} + notify: restart postfix + +- name: create postman group + group: name=postman state=present + +- name: create postman user + user: name=postman state=present shell=/dev/null + +- name: edit dovecot configuration + lineinfile: dest=/etc/dovecot/conf.d/10-master.conf line=' port = 143' insertafter='inet_listener imap {' state=present + notify: restart dovecot + +- blockinfile: + dest: /etc/dovecot/conf.d/10-master.conf + insertafter: 'inet_listener imaps {' + marker: '#ANSIBLE BLOCK FOR IMAPS PORT' + block: | + port = 993 + ssl = yes + notify: restart dovecot + +- blockinfile: + dest: "/etc/dovecot/conf.d/10-master.conf" + insertafter: "unix_listener auth-userdb {" + marker: '#ANSIBLE BLOCK FOR AUTH USER' + block: | + group = postman + mode = 0664 + user = postman + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-mail.conf line='mail_location = maildir:/home/postman/%d/%n' regexp='^mail_location = ' state=present + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-mail.conf line='mail_gid = postman' state=present + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-mail.conf line='mail_uid = postman' state=present + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="!include auth-system.conf.ext" state=absent + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="!include auth-ldap.conf.ext" state=present + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="auth_default_realm = {{ fqdn_domain }}" + notify: restart dovecot + +- lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="auth_mechanisms = login plain" + notify: restart dovecot + +- blockinfile: + dest: /etc/dovecot/conf.d/10-ssl.conf + block: | + ssl = yes + ssl_cert = array( 'verify_peer' => false,