From 5bbae181ee7f3bb9a05b567db98f8bd283368211 Mon Sep 17 00:00:00 2001 From: Andrea Cimbalo Date: Thu, 18 Aug 2016 01:47:46 +0200 Subject: [PATCH] add ssl certificate to dovecot --- files/test_ssl_ca.crt | 33 ++++++++ mail.yaml | 5 +- roles/dovecot/tasks/main.yaml | 79 +++++++++++++++++-- roles/roundcube/handlers/main.yaml | 2 + roles/roundcube/tasks/main.yaml | 13 +++ roles/roundcube/templates/my-roundcube.php.j2 | 16 ++-- webmail.yaml | 3 +- 7 files changed, 131 insertions(+), 20 deletions(-) create mode 100644 files/test_ssl_ca.crt create mode 100644 roles/roundcube/handlers/main.yaml diff --git a/files/test_ssl_ca.crt b/files/test_ssl_ca.crt new file mode 100644 index 0000000..f1b4d70 --- /dev/null +++ b/files/test_ssl_ca.crt @@ -0,0 +1,33 @@ +-----BEGIN CERTIFICATE----- +MIIFoTCCA4mgAwIBAgIJAPczDYaGgRcwMA0GCSqGSIb3DQEBCwUAMGcxCzAJBgNV +BAYTAklUMQ4wDAYDVQQIDAVJVEFMWTERMA8GA1UEBwwIRmxvcmVuY2UxDjAMBgNV +BAoMBUxJTGlLMQ8wDQYDVQQLDAZzc2wgQ0ExFDASBgNVBAMMC2NhLmxpbGlrLml0 +MB4XDTE2MDgxNzIyMzEzNVoXDTE3MDgxNzIyMzEzNVowZzELMAkGA1UEBhMCSVQx +DjAMBgNVBAgMBUlUQUxZMREwDwYDVQQHDAhGbG9yZW5jZTEOMAwGA1UECgwFTElM +aUsxDzANBgNVBAsMBnNzbCBDQTEUMBIGA1UEAwwLY2EubGlsaWsuaXQwggIiMA0G +CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCg2edLFA7/GGxVm9U0ctmw06/kVFuN +387nkGabnd0QcpII3bJtraD52IdCDNburtvxxyAF6KOty9+YLtPNf8TZKj6aJE0W +cOmNuvSk01LzHkR2aUtu6b72IZMEJlJ/5eZkVVOMl+e9e6K4TtkbkV3ymHf4wuru +Jj2fZFRJJC5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LmseLow +PJsEXfRR9PYFe4JwrBEKAPqjNufmnWTuAJ2GK8OwdaAwVaBp7LpPH8j7Wki1EZrA +6usoEsEQ5onjssl/lvXFJtUToo4kQlDXmrPEWj4rnpkpi8EP2JQ1bK3wShi9EAym +GwUzqDBckCEp1REwppMX9h+eQxE3fC9+FpeBQNqs56iNEIT5hQzau4/bDzMkfVV4 +KPUjgGto/t3djwrmIZVdt1p/+0aMCWjWJdi27y0U4aK5lCqQwgGRGXmWbgpMgrV4 +Q/EXp+A= +-----END CERTIFICATE----- diff --git a/mail.yaml b/mail.yaml index 97a080d..c8bdd0a 100644 --- a/mail.yaml +++ b/mail.yaml @@ -7,8 +7,9 @@ roles: - role: postfix ldap_server: "{{ hostvars['ldap'].ansible_host }}" - fqdn_domain: "lilik.it" + fqdn_domain: "mail.lilik.it" lists_server: "{{ hostvars['lists'].ansible_host }}" - role: dovecot - fqdn_domain: "lilik.it" + domain: "lilik.it" + fqdn_domain: "mail.lilik.it" ldap_server: "{{ hostvars['ldap'].ansible_host }}" diff --git a/roles/dovecot/tasks/main.yaml b/roles/dovecot/tasks/main.yaml index d93c860..9711ce3 100644 --- a/roles/dovecot/tasks/main.yaml +++ b/roles/dovecot/tasks/main.yaml @@ -61,25 +61,88 @@ - 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 }}" +- lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="auth_default_realm = {{ domain }}" notify: restart dovecot - lineinfile: dest=/etc/dovecot/conf.d/10-auth.conf line="auth_mechanisms = login plain" notify: restart dovecot -- blockinfile: +- name: enable ssl key + blockinfile: dest: /etc/dovecot/conf.d/10-ssl.conf block: | ssl = yes - ssl_cert = /etc/dovecot/dovecot.cert" + register: set_pub_key + when: not dovecot_cert_key.stat.exists + - template: src=dovecot-ldap.conf.ext.j2 dest=/etc/dovecot/dovecot-ldap.conf.ext notify: restart dovecot diff --git a/roles/roundcube/handlers/main.yaml b/roles/roundcube/handlers/main.yaml new file mode 100644 index 0000000..bdd7ff1 --- /dev/null +++ b/roles/roundcube/handlers/main.yaml @@ -0,0 +1,2 @@ +- name: update-ca-certificates + shell: update-ca-certificates diff --git a/roles/roundcube/tasks/main.yaml b/roles/roundcube/tasks/main.yaml index 3deb1dd..cbe8ea8 100644 --- a/roles/roundcube/tasks/main.yaml +++ b/roles/roundcube/tasks/main.yaml @@ -27,6 +27,19 @@ owner: root group: www-data +- name: copy test_ssl_ca.crt + copy: + src: "test_ssl_ca.crt" + dest: "/usr/local/share/ca-certificates/test_ssl_ca.crt" + mode: 0444 + notify: update-ca-certificates + +#TODO: remove when dovecot will use a valid dns record +- name: '(FIX REMOVE THIS ACTION) add temporary host record' + lineinfile: + dest: /etc/hosts + line: "{{ hostvars['mail'].ansible_host }} {{ mail_server }}" + regexp: "{{ mail_server }}$" - name: include my-roundcube.php lineinfile: diff --git a/roles/roundcube/templates/my-roundcube.php.j2 b/roles/roundcube/templates/my-roundcube.php.j2 index 3898248..6796ced 100644 --- a/roles/roundcube/templates/my-roundcube.php.j2 +++ b/roles/roundcube/templates/my-roundcube.php.j2 @@ -1,8 +1,8 @@ array( - 'verify_peer' => false, - 'verfify_peer_name' => false, - ), -); +#$config['imap_conn_options'] = array( +# 'ssl' => array( +# 'verify_peer' => false, +# 'verfify_peer_name' => false, +# ), +#); diff --git a/webmail.yaml b/webmail.yaml index d54ac9c..96bb621 100644 --- a/webmail.yaml +++ b/webmail.yaml @@ -6,5 +6,4 @@ - hosts: webmail roles: - role: roundcube - # imap_server: "{{ hostvars['mail'].ansible_host }}" - # fqdn_domain: "lilik.it" + mail_server: "mail.lilik.it"