From 3b6a2f700476bcb9578bf2b93281617eac359c26 Mon Sep 17 00:00:00 2001 From: genofire Date: Fri, 24 Jul 2020 18:08:57 +0200 Subject: [PATCH] fix roundcubemail --- defaults/main.yml | 7 +++++++ tasks/main.yml | 9 +++++++-- tasks/roundcubemail.yml | 25 +++++++++++++++++++++++++ templates/roundcubemail-conf.php | 12 ++++++------ templates/roundcubemail-local.nginx | 6 +----- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index a980093..1d0c086 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -34,3 +34,10 @@ mailserver_mailman_domains: mailserver_roundcubemail_enabled: true mailserver_roundcubemail_domain: "" +mailserver_roundcubemail_enabled_installer: false +mailserver_roundcubemail_db_create_schema: false # run once with true +mailserver_roundcubemail_db_type: "pgsql" +mailserver_roundcubemail_db_host: "localhost" +mailserver_roundcubemail_db_name: "roundcubemail" +mailserver_roundcubemail_db_user: "roundcubemail" +mailserver_roundcubemail_db_password: "{{ lookup('password', 'credentials/' + inventory_hostname + '/mailserver/roundcubemail_db_password length=15') }}" diff --git a/tasks/main.yml b/tasks/main.yml index b791562..06bdbec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -23,9 +23,14 @@ line: "{{ mailserver_cert_domains }}" - name: Run userdatabase - when: mailserver_dovecot_enabled + when: mailserver_dovecot_enabled or mailserver_roundcubemail_enabled import_tasks: db.yml - tags: mail-db + tags: + - mail-db + - postfixadmin + - dovecot + - postfix + - roundcubemail - name: Run postfixadmin when: mailserver_dovecot_enabled diff --git a/tasks/roundcubemail.yml b/tasks/roundcubemail.yml index 5ca63a6..b35f117 100644 --- a/tasks/roundcubemail.yml +++ b/tasks/roundcubemail.yml @@ -3,6 +3,31 @@ name: roundcubemail state: latest +- name: roundcubemail - create user + postgresql_user: + login_host: "{{ mailserver_roundcubemail_db_host }}" + name: "{{ mailserver_roundcubemail_db_user }}" + password: "{{ mailserver_roundcubemail_db_password }}" + +- name: roundcubemail - create database + postgresql_db: + login_host: "{{ mailserver_roundcubemail_db_host }}" + name: "{{ mailserver_roundcubemail_db_name }}" + owner: "{{ mailserver_roundcubemail_db_user }}" + encoding: UTF-8 + lc_collate: en_US.UTF-8 + lc_ctype: en_US.UTF-8 + + +- name: roundcubemail - create tables + when: mailserver_roundcubemail_db_create_schema + postgresql_query: + login_host: "{{ mailserver_roundcubemail_db_host }}" + login_user: "{{ mailserver_roundcubemail_db_user }}" + login_password: "{{ mailserver_roundcubemail_db_password }}" + db: "{{ mailserver_roundcubemail_db_name }}" + path_to_script: /usr/share/webapps/roundcubemail/SQL/postgres.initial.sql + - name: roundcubemail - nginx local notify: reload nginx when: mailserver_roundcubemail_domain == "" diff --git a/templates/roundcubemail-conf.php b/templates/roundcubemail-conf.php index 88dd2f6..8246d1b 100644 --- a/templates/roundcubemail-conf.php +++ b/templates/roundcubemail-conf.php @@ -25,7 +25,7 @@ $config = array(); // For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php // NOTE: for SQLite use absolute path (Linux): 'sqlite:////full/path/to/sqlite.db?mode=0646' // or (Windows): 'sqlite:///C:/full/path/to/sqlite.db' -$config['db_dsnw'] = 'mysql://roundcube:JAoHRkIPdsCC3woD52cfy5Eu@localhost:3306/roundcube'; +$config['db_dsnw'] = '{{ mailserver_roundcubemail_db_type }}://{{ mailserver_roundcubemail_db_user }}:{{ mailserver_roundcubemail_db_password }}@{{ mailserver_roundcubemail_db_host }}/{{ mailserver_roundcubemail_db_name }}'; // The mail host chosen to perform the log-in. // Leave blank to show a textbox at login, give a list of hosts @@ -37,7 +37,7 @@ $config['db_dsnw'] = 'mysql://roundcube:JAoHRkIPdsCC3woD52cfy5Eu@localhost:3306/ // %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part) // %s - domain name after the '@' from e-mail address provided at login screen // For example %n = mail.domain.tld, %t = domain.tld -$config['default_host'] = 'ssl://mail.sum7.eu'; +$config['default_host'] = 'ssl://{{ mailserver_mx_domain }}'; // SMTP server host (for sending mails). // To use SSL/TLS connection, enter hostname with prefix ssl:// or tls:// @@ -49,7 +49,7 @@ $config['default_host'] = 'ssl://mail.sum7.eu'; // %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part) // %z - IMAP domain (IMAP hostname without the first part) // For example %n = mail.domain.tld, %t = domain.tld -$config['smtp_server'] = 'tls://mail.sum7.eu'; +$config['smtp_server'] = 'tls://{{ mailserver_mx_domain }}'; // SMTP port (default is 25; use 587 for STARTTLS or 465 for the // deprecated SSL over SMTP (aka SMTPS)) @@ -75,7 +75,7 @@ $config['product_name'] = 'Webmail'; // in the session record (and the client cookie if remember password is enabled). // please provide a string of exactly 24 chars. // YOUR KEY MUST BE DIFFERENT THAN THE SAMPLE VALUE FOR SECURITY REASONS -$config['des_key'] = 'oaV96vtQ6simuPuDgpABGKF7'; +$//config['des_key'] = 'oaV96vtQ6simuPuDgpABGKF7'; // List of active plugins (in plugins/ directory) $config['plugins'] = array( @@ -85,7 +85,7 @@ $config['plugins'] = array( ); // skin name: folder from skins/ -$config['skin'] = 'sum7'; +//$config['skin'] = 'sum7'; $config['skin_logo'] = 'https://sum7.eu/img/logo.svg'; -$config['enable_installer'] = false; +$config['enable_installer'] = {{ mailserver_roundcubemail_enabled_installer }}; diff --git a/templates/roundcubemail-local.nginx b/templates/roundcubemail-local.nginx index 53fd318..dcd160c 100644 --- a/templates/roundcubemail-local.nginx +++ b/templates/roundcubemail-local.nginx @@ -1,8 +1,4 @@ location /roundcubemail { - rewrite ^/roundcubemail/?(.*)$ /roundcubemail/public_html/$1 last; -} - -location /roundcubemail/public_html { root /usr/share/webapps; index index.html index.htm index.php; @@ -13,7 +9,7 @@ location /roundcubemail/public_html { include fastcgi.conf; - fastcgi_param PHP_ADMIN_VALUE open_basedir=/etc/webapps/roundcubemail/:/usr/share/webapps/roundcubemail:/var/logs/roundcubemail/:/var/cache/roundcubemail/:/tmp:/usr/share/pear:/dev/urandom; + fastcgi_param PHP_ADMIN_VALUE open_basedir=/etc/webapps/roundcubemail/:/usr/share/webapps/roundcubemail:/var/log/roundcubemail/:/var/cache/roundcubemail/:/tmp:/usr/share/pear:/dev/urandom; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param HTTPS on;