From 0d2f8bee3a440cd86f85d229519d17ede3cf0f47 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 16:57:06 +0100 Subject: [PATCH 1/7] Setting vhost name to IP of Vagrant box --- group_vars/all | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/group_vars/all b/group_vars/all index af0df44..e844eaf 100644 --- a/group_vars/all +++ b/group_vars/all @@ -7,7 +7,8 @@ ispmail_dovecot_auth_mechanisms: plain login ispmail_postmaster_address: postmaster@example.org -ispmail_webmail_hostname: mail.example.org +#ispmail_webmail_hostname: mail.example.org +ispmail_webmail_hostname: 10.0.0.100 ispmail_certificate_country: DE ispmail_certificate_state: Hamburg From 75bfe041c75fd72f95b399353e83dae800ffea50 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 16:57:53 +0100 Subject: [PATCH 2/7] Avoid setting the MySQL root password It would break idempotency of the Ansible role --- roles/ispmail-database/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/ispmail-database/tasks/main.yml b/roles/ispmail-database/tasks/main.yml index fb3488a..71fb123 100644 --- a/roles/ispmail-database/tasks/main.yml +++ b/roles/ispmail-database/tasks/main.yml @@ -7,8 +7,6 @@ copy: src=schema.sql dest=/tmp - name: setting up SQL schema of mailserver database mysql_db: name=mailserver state=import target=/tmp/schema.sql -- name: set the MySQL root user's password - mysql_user: name=root password={{ispmail_mysql_root_password}} state=present - name: creating MySQL user to read the mailserver database mysql_user: name=mailuser password={{ispmail_mysql_mailuser_password}} priv=mailserver.*:SELECT,INSERT,UPDATE,DELETE state=present - name: copying MySQL test data to server @@ -17,3 +15,7 @@ - name: populating the database with test data mysql_db: name=mailserver state=import target=/tmp/test.sql when: ispmail_populate_test_data == true +# - name: set the MySQL root user's password +# mysql_user: name=root password={{ispmail_mysql_root_password}} state=present +# - name: Create root's .my.cnf +# template: src=my-cnf.j2 dest=/root/.my.cnf mode=0600 From 05d07441c52aba1fa3967b45a2536d7ad4870fc3 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 16:58:38 +0100 Subject: [PATCH 3/7] Creating Roundcube database config include file --- group_vars/all | 1 + roles/ispmail-database/tasks/main.yml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/group_vars/all b/group_vars/all index e844eaf..559d932 100644 --- a/group_vars/all +++ b/group_vars/all @@ -2,6 +2,7 @@ ispmail_populate_test_data: true ispmail_mysql_mailuser_password: ChangeMe ispmail_mysql_root_password: ChangeMeRoot +ispmail_mysql_roundcube_password: ChangeMeRound ispmail_dovecot_auth_mechanisms: plain login diff --git a/roles/ispmail-database/tasks/main.yml b/roles/ispmail-database/tasks/main.yml index 71fb123..9ccbe3b 100644 --- a/roles/ispmail-database/tasks/main.yml +++ b/roles/ispmail-database/tasks/main.yml @@ -3,12 +3,16 @@ apt: pkg=python-mysqldb state=installed - name: creating mailserver MySQL database mysql_db: name=mailserver state=present +- name: creating Roundcube MySQL database + mysql_db: name=roundcube state=present - name: copying MySQL database schema to server copy: src=schema.sql dest=/tmp - name: setting up SQL schema of mailserver database mysql_db: name=mailserver state=import target=/tmp/schema.sql - name: creating MySQL user to read the mailserver database mysql_user: name=mailuser password={{ispmail_mysql_mailuser_password}} priv=mailserver.*:SELECT,INSERT,UPDATE,DELETE state=present +- name: creating MySQL user for roundcube + mysql_user: name=roundcube password={{ispmail_mysql_roundcube_password}} priv=roundcube.*:ALL state=present - name: copying MySQL test data to server copy: src=test.sql dest=/tmp when: ispmail_populate_test_data == true From c653177bf72de4934221e782e8f1bc49baf43616 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 17:28:56 +0100 Subject: [PATCH 4/7] Fixed Apache vhosts (80 and 443) --- roles/ispmail-webmail-apache/tasks/main.yml | 16 +-- .../templates/webmail.conf-443.j2 | 139 ++++++++++++++++++++ .../templates/webmail.conf-80.j2 | 6 + .../templates/webmail.conf.j2 | 140 --------------------- 4 files changed, 154 insertions(+), 147 deletions(-) create mode 100644 roles/ispmail-webmail-apache/templates/webmail.conf-443.j2 create mode 100644 roles/ispmail-webmail-apache/templates/webmail.conf-80.j2 delete mode 100644 roles/ispmail-webmail-apache/templates/webmail.conf.j2 diff --git a/roles/ispmail-webmail-apache/tasks/main.yml b/roles/ispmail-webmail-apache/tasks/main.yml index 0f0cc09..8d3bd1a 100644 --- a/roles/ispmail-webmail-apache/tasks/main.yml +++ b/roles/ispmail-webmail-apache/tasks/main.yml @@ -1,16 +1,18 @@ -- name: install required binary packages +- name: Install required binary packages apt: name={{item}} state=installed with_items: - apache2 - libapache2-mod-php5 notify: restart apache -- name: Create Apache vhost configuration for Webmail - template: src=webmail.conf.j2 dest=/etc/apache2/sites-available/webmail.conf +- name: Create Apache vhost configuration for HTTPS (RoundCube and PHPmyadmin) + template: src=webmail.conf-443.j2 dest=/etc/apache2/sites-available/default-ssl.conf notify: restart apache -- name: Enable Apache vhost - command: /usr/sbin/a2ensite webmail.conf creates=/etc/apache2/sites-enabled/webmail.conf +- name: Enable Apache vhost for HTTPS + command: /usr/sbin/a2ensite default-ssl creates=/etc/apache2/sites-enabled/default-ssl.conf notify: restart apache -- name: Enabling Apache SSL module +- name: Create Apache vhost configuration for HTTP (redirect to HTTPS) + template: src=webmail.conf-80.j2 dest=/etc/apache2/sites-available/000-default.conf + notify: restart apache +- name: Enable Apache SSL module command: /usr/sbin/a2enmod ssl creates=/etc/apache2/mods-enabled/ssl.conf notify: restart apache - diff --git a/roles/ispmail-webmail-apache/templates/webmail.conf-443.j2 b/roles/ispmail-webmail-apache/templates/webmail.conf-443.j2 new file mode 100644 index 0000000..6019705 --- /dev/null +++ b/roles/ispmail-webmail-apache/templates/webmail.conf-443.j2 @@ -0,0 +1,139 @@ + + + ServerAdmin {{ ispmail_postmaster_address }} + ServerName {{ ispmail_webmail_hostname }} + + Include /etc/roundcube/apache.conf + Alias / /var/lib/roundcube/ + + # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, + # error, crit, alert, emerg. + # It is also possible to configure the loglevel for particular + # modules, e.g. + #LogLevel info ssl:warn + + ErrorLog ${APACHE_LOG_DIR}/webmail.error.log + CustomLog ${APACHE_LOG_DIR}/webmail.access.log combined + + # For most configuration files from conf-available/, which are + # enabled or disabled at a global level, it is possible to + # include a line for only one particular virtual host. For example the + # following line enables the CGI configuration for this host only + # after it has been globally disabled with "a2disconf". + #Include conf-available/serve-cgi-bin.conf + + # SSL Engine Switch: + # Enable/Disable SSL for this virtual host. + SSLEngine on + + # A self-signed (snakeoil) certificate can be created by installing + # the ssl-cert package. See + # /usr/share/doc/apache2/README.Debian.gz for more info. + # If both key and certificate are stored in the same file, only the + # SSLCertificateFile directive is needed. + SSLCertificateFile /etc/ssl/certs/mailserver.pem + SSLCertificateKeyFile /etc/ssl/private/mailserver.pem + + # Server Certificate Chain: + # Point SSLCertificateChainFile at a file containing the + # concatenation of PEM encoded CA certificates which form the + # certificate chain for the server certificate. Alternatively + # the referenced file can be the same as SSLCertificateFile + # when the CA certificates are directly appended to the server + # certificate for convinience. + #SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt + + # Certificate Authority (CA): + # Set the CA certificate verification path where to find CA + # certificates for client authentication or alternatively one + # huge file containing all of them (file must be PEM encoded) + # Note: Inside SSLCACertificatePath you need hash symlinks + # to point to the certificate files. Use the provided + # Makefile to update the hash symlinks after changes. + #SSLCACertificatePath /etc/ssl/certs/ + #SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt + + # Certificate Revocation Lists (CRL): + # Set the CA revocation path where to find CA CRLs for client + # authentication or alternatively one huge file containing all + # of them (file must be PEM encoded) + # Note: Inside SSLCARevocationPath you need hash symlinks + # to point to the certificate files. Use the provided + # Makefile to update the hash symlinks after changes. + #SSLCARevocationPath /etc/apache2/ssl.crl/ + #SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl + + # Client Authentication (Type): + # Client certificate verification type and depth. Types are + # none, optional, require and optional_no_ca. Depth is a + # number which specifies how deeply to verify the certificate + # issuer chain before deciding the certificate is not valid. + #SSLVerifyClient require + #SSLVerifyDepth 10 + + # SSL Engine Options: + # Set various options for the SSL engine. + # o FakeBasicAuth: + # Translate the client X.509 into a Basic Authorisation. This means that + # the standard Auth/DBMAuth methods can be used for access control. The + # user name is the `one line' version of the client's X.509 certificate. + # Note that no password is obtained from the user. Every entry in the user + # file needs this password: `xxj31ZMTZzkVA'. + # o ExportCertData: + # This exports two additional environment variables: SSL_CLIENT_CERT and + # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the + # server (always existing) and the client (only existing when client + # authentication is used). This can be used to import the certificates + # into CGI scripts. + # o StdEnvVars: + # This exports the standard SSL/TLS related `SSL_*' environment variables. + # Per default this exportation is switched off for performance reasons, + # because the extraction step is an expensive operation and is usually + # useless for serving static content. So one usually enables the + # exportation for CGI and SSI requests only. + # o OptRenegotiate: + # This enables optimized SSL connection renegotiation handling when SSL + # directives are used in per-directory context. + #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + # SSL Protocol Adjustments: + # The safe and default but still SSL/TLS standard compliant shutdown + # approach is that mod_ssl sends the close notify alert but doesn't wait for + # the close notify alert from client. When you need a different shutdown + # approach you can use one of the following variables: + # o ssl-unclean-shutdown: + # This forces an unclean shutdown when the connection is closed, i.e. no + # SSL close notify alert is send or allowed to received. This violates + # the SSL/TLS standard but is needed for some brain-dead browsers. Use + # this when you receive I/O errors because of the standard approach where + # mod_ssl sends the close notify alert. + # o ssl-accurate-shutdown: + # This forces an accurate shutdown when the connection is closed, i.e. a + # SSL close notify alert is send and mod_ssl waits for the close notify + # alert of the client. This is 100% SSL/TLS standard compliant, but in + # practice often causes hanging connections with brain-dead browsers. Use + # this only for browsers where you know that their SSL implementation + # works correctly. + # Notice: Most problems of broken clients are also related to the HTTP + # keep-alive facility, so you usually additionally want to disable + # keep-alive for those clients, too. Use variable "nokeepalive" for this. + # Similarly, one has to force some clients to use HTTP/1.0 to workaround + # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and + # "force-response-1.0" for this. + BrowserMatch "MSIE [2-6]" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown + + + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet + diff --git a/roles/ispmail-webmail-apache/templates/webmail.conf-80.j2 b/roles/ispmail-webmail-apache/templates/webmail.conf-80.j2 new file mode 100644 index 0000000..59589bc --- /dev/null +++ b/roles/ispmail-webmail-apache/templates/webmail.conf-80.j2 @@ -0,0 +1,6 @@ + + ServerAdmin {{ ispmail_postmaster_address }} + ServerName {{ ispmail_webmail_hostname }} + + Redirect permanent / https://{{ ispmail_webmail_hostname}}/ + diff --git a/roles/ispmail-webmail-apache/templates/webmail.conf.j2 b/roles/ispmail-webmail-apache/templates/webmail.conf.j2 deleted file mode 100644 index 9aa7cd1..0000000 --- a/roles/ispmail-webmail-apache/templates/webmail.conf.j2 +++ /dev/null @@ -1,140 +0,0 @@ - - - ServerAdmin webmaster@localhost - ServerName {{ ispmail_webmail_hostname }} - - #DocumentRoot /var/www/html - Include /etc/roundcube/apache.conf - Alias /roundcube /var/lib/roundcube - - # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, - # error, crit, alert, emerg. - # It is also possible to configure the loglevel for particular - # modules, e.g. - #LogLevel info ssl:warn - - ErrorLog ${APACHE_LOG_DIR}/webmail.error.log - CustomLog ${APACHE_LOG_DIR}/webmail.access.log combined - - # For most configuration files from conf-available/, which are - # enabled or disabled at a global level, it is possible to - # include a line for only one particular virtual host. For example the - # following line enables the CGI configuration for this host only - # after it has been globally disabled with "a2disconf". - #Include conf-available/serve-cgi-bin.conf - - # SSL Engine Switch: - # Enable/Disable SSL for this virtual host. - SSLEngine on - - # A self-signed (snakeoil) certificate can be created by installing - # the ssl-cert package. See - # /usr/share/doc/apache2/README.Debian.gz for more info. - # If both key and certificate are stored in the same file, only the - # SSLCertificateFile directive is needed. - SSLCertificateFile /etc/ssl/certs/mailserver.pem - SSLCertificateKeyFile /etc/ssl/private/mailserver.pem - - # Server Certificate Chain: - # Point SSLCertificateChainFile at a file containing the - # concatenation of PEM encoded CA certificates which form the - # certificate chain for the server certificate. Alternatively - # the referenced file can be the same as SSLCertificateFile - # when the CA certificates are directly appended to the server - # certificate for convinience. - #SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt - - # Certificate Authority (CA): - # Set the CA certificate verification path where to find CA - # certificates for client authentication or alternatively one - # huge file containing all of them (file must be PEM encoded) - # Note: Inside SSLCACertificatePath you need hash symlinks - # to point to the certificate files. Use the provided - # Makefile to update the hash symlinks after changes. - #SSLCACertificatePath /etc/ssl/certs/ - #SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt - - # Certificate Revocation Lists (CRL): - # Set the CA revocation path where to find CA CRLs for client - # authentication or alternatively one huge file containing all - # of them (file must be PEM encoded) - # Note: Inside SSLCARevocationPath you need hash symlinks - # to point to the certificate files. Use the provided - # Makefile to update the hash symlinks after changes. - #SSLCARevocationPath /etc/apache2/ssl.crl/ - #SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl - - # Client Authentication (Type): - # Client certificate verification type and depth. Types are - # none, optional, require and optional_no_ca. Depth is a - # number which specifies how deeply to verify the certificate - # issuer chain before deciding the certificate is not valid. - #SSLVerifyClient require - #SSLVerifyDepth 10 - - # SSL Engine Options: - # Set various options for the SSL engine. - # o FakeBasicAuth: - # Translate the client X.509 into a Basic Authorisation. This means that - # the standard Auth/DBMAuth methods can be used for access control. The - # user name is the `one line' version of the client's X.509 certificate. - # Note that no password is obtained from the user. Every entry in the user - # file needs this password: `xxj31ZMTZzkVA'. - # o ExportCertData: - # This exports two additional environment variables: SSL_CLIENT_CERT and - # SSL_SERVER_CERT. These contain the PEM-encoded certificates of the - # server (always existing) and the client (only existing when client - # authentication is used). This can be used to import the certificates - # into CGI scripts. - # o StdEnvVars: - # This exports the standard SSL/TLS related `SSL_*' environment variables. - # Per default this exportation is switched off for performance reasons, - # because the extraction step is an expensive operation and is usually - # useless for serving static content. So one usually enables the - # exportation for CGI and SSI requests only. - # o OptRenegotiate: - # This enables optimized SSL connection renegotiation handling when SSL - # directives are used in per-directory context. - #SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire - - SSLOptions +StdEnvVars - - - SSLOptions +StdEnvVars - - - # SSL Protocol Adjustments: - # The safe and default but still SSL/TLS standard compliant shutdown - # approach is that mod_ssl sends the close notify alert but doesn't wait for - # the close notify alert from client. When you need a different shutdown - # approach you can use one of the following variables: - # o ssl-unclean-shutdown: - # This forces an unclean shutdown when the connection is closed, i.e. no - # SSL close notify alert is send or allowed to received. This violates - # the SSL/TLS standard but is needed for some brain-dead browsers. Use - # this when you receive I/O errors because of the standard approach where - # mod_ssl sends the close notify alert. - # o ssl-accurate-shutdown: - # This forces an accurate shutdown when the connection is closed, i.e. a - # SSL close notify alert is send and mod_ssl waits for the close notify - # alert of the client. This is 100% SSL/TLS standard compliant, but in - # practice often causes hanging connections with brain-dead browsers. Use - # this only for browsers where you know that their SSL implementation - # works correctly. - # Notice: Most problems of broken clients are also related to the HTTP - # keep-alive facility, so you usually additionally want to disable - # keep-alive for those clients, too. Use variable "nokeepalive" for this. - # Similarly, one has to force some clients to use HTTP/1.0 to workaround - # their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and - # "force-response-1.0" for this. - BrowserMatch "MSIE [2-6]" \ - nokeepalive ssl-unclean-shutdown \ - downgrade-1.0 force-response-1.0 - # MSIE 7 and newer should be able to use keepalive - BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown - - - - -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet - From 5790351bde73e68517f5cb428bf9a1471d27dfff Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 17:29:13 +0100 Subject: [PATCH 5/7] Deploying Roundcube database config file --- roles/ispmail-webmail/tasks/main.yml | 3 ++- roles/ispmail-webmail/templates/roundcube-debian-db.php.j2 | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 roles/ispmail-webmail/templates/roundcube-debian-db.php.j2 diff --git a/roles/ispmail-webmail/tasks/main.yml b/roles/ispmail-webmail/tasks/main.yml index 16c3cb1..277c942 100644 --- a/roles/ispmail-webmail/tasks/main.yml +++ b/roles/ispmail-webmail/tasks/main.yml @@ -17,4 +17,5 @@ template: src=roundcube-password-config.inc.php.j2 dest=/etc/roundcube/plugins/password/config.inc.php owner=root group=www-data mode=640 - name: Copy ISPmail logo copy: src=ispmail-logo.png dest=/var/lib/roundcube/ - +- name: Copy Roundcube database config file + template: src=roundcube-debian-db.php.j2 dest=/etc/roundcube/debian-db.php mode=0640 diff --git a/roles/ispmail-webmail/templates/roundcube-debian-db.php.j2 b/roles/ispmail-webmail/templates/roundcube-debian-db.php.j2 new file mode 100644 index 0000000..5214684 --- /dev/null +++ b/roles/ispmail-webmail/templates/roundcube-debian-db.php.j2 @@ -0,0 +1,8 @@ + Date: Sun, 1 Nov 2015 17:29:55 +0100 Subject: [PATCH 6/7] Added template for ~root/.my.cnf --- roles/ispmail-database/templates/my-cnf.j2 | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 roles/ispmail-database/templates/my-cnf.j2 diff --git a/roles/ispmail-database/templates/my-cnf.j2 b/roles/ispmail-database/templates/my-cnf.j2 new file mode 100644 index 0000000..0615332 --- /dev/null +++ b/roles/ispmail-database/templates/my-cnf.j2 @@ -0,0 +1,2 @@ +[client] +password={{ispmail_mysql_root_password}} From d945bf3cad39b055c2a52bc07a4e72bffc1736a2 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Sun, 1 Nov 2015 17:40:46 +0100 Subject: [PATCH 7/7] Redundant variable definition removed --- group_vars/all | 2 -- 1 file changed, 2 deletions(-) diff --git a/group_vars/all b/group_vars/all index 559d932..489009c 100644 --- a/group_vars/all +++ b/group_vars/all @@ -20,5 +20,3 @@ ispmail_certificate_domains: - example.org ispmail_certificate_email: postmaster@example.org ispmail_certificate_days_valid: 3650 - -ispmail_postmaster_address: postmaster@example.org