ansible-role-roundcube/tasks/roundcube-install.yml

94 lines
4.0 KiB
YAML

---
- name: Prepare roundcube for upgrade
block:
- name: Remove the roundcube current installation
file: dest={{ roundcube_web_root }} state=absent
when: roundcube_upgrade | bool
tags: [ 'roundcube', 'roundcube_upgrade' ]
- name: Install Roundcube
block:
- name: Create the roundcube webroot
file: dest={{ roundcube_web_basedir }} owner=root group=root state=directory
- name: Create the roundcube base data directory
file: dest={{ roundcube_data_dir }} owner=root group=root state=directory
- name: Create the roundcube data directories
file: dest={{ item }} state=directory owner={{ roundcube_user }} group={{ roundcube_user }}
with_items:
- '{{ roundcube_logs_dir }}'
- '{{ roundcube_temp_dir }}'
- name: Unpack the roundcube archive
unarchive: remote_src=yes src={{ roundcube_download_url }} dest={{ roundcube_data_dir }} owner=root group=root
args:
creates: '{{ roundcube_web_root }}/public_html/index.php'
- name: Move the roundcube installation to the final place
shell: mv {{ roundcube_data_dir }}/{{ roundcube_dist }} {{ roundcube_web_root }}
args:
creates: '{{ roundcube_web_root }}/public_html/index.php'
tags: [ 'roundcube' ]
- name: Manage some additional plugins
block:
- name: Install the identity_smtp plugin
git: repo={{ roundcube_identity_smtp_git }} dest={{ roundcube_web_root }}/plugins/{{ roundcube_identity_smtp_name }}
when: roundcube_identity_smtp_plugin | bool
tags: [ 'roundcube', 'roundcube_plugins', 'roundcube_config' ]
- name: Manage the Enigma (PGP) plugin
block:
- name: Create the enigma data directory
file: dest={{ roundcube_enigma_data_dir }} state=directory owner={{ roundcube_user }} group={{ roundcube_user }}
- name: Install the gnupg packages
apt: pkg={{ roundcube_enigma_deps }} state=present cache_valid_time=1800
when: roundcube_install_enigma | bool
tags: [ 'roundcube', 'roundcube_plugins', 'roundcube_config', 'roundcube_enigma' ]
- name: Manage the Spamassassin preferences plugin and its dependency
block:
- name: Install the sauserprefs plugin
git: repo={{ roundcube_sauserprefs_git }} dest={{ roundcube_web_root }}/plugins/{{ roundcube_sauserprefs_plugin_name }} version={{ roundcube_sauserprefs_version }}
- name: Install the sauserprefs plugin configuration
template: src=sauserprefs-config.inc.php.j2 dest={{ roundcube_web_root }}/plugins/{{ roundcube_sauserprefs_plugin_name }}/config.inc.php owner=root group={{ roundcube_user }} mode=0440
when: roundcube_sauserprefs_plugin_install | bool
tags: [ 'roundcube', 'roundcube_plugins', 'roundcube_config', 'roundcube_sauserprefs' ]
- name: Remove the Spamassassin preferences plugin when not enabled
block:
- name: Remove the sauserprefs plugin
file: dest={{ roundcube_web_root }}/plugins/{{ roundcube_sauserprefs_plugin_name }} state=absent
when: not roundcube_sauserprefs_plugin_install | bool
tags: [ 'roundcube', 'roundcube_plugins', 'roundcube_config', 'roundcube_sauserprefs' ]
- block:
- name: Configure the roundcube instance
template: src=config.inc.php.j2 dest={{ roundcube_web_root }}/config/config.inc.php owner=root group={{ roundcube_user }} mode=0440
- name: Initialize the roundcube database
shell: PGPASSWORD={{ roundcube_db_pwd }} psql -h {{ roundcube_db_host }} -U {{ roundcube_db_user }} -f {{ roundcube_web_root }}/SQL/postgres.initial.sql {{ roundcube_db_name }} && touch {{ roundcube_logs_dir }}/.roundcube_db.initialized
args:
creates: '{{ roundcube_logs_dir }}/.roundcube_db.initialized'
tags: [ 'roundcube', 'roundcube_config' ]
- block:
- name: Upgrade the roundcube DB
shell: cd {{ roundcube_web_root }} && ./bin/update.sh --version {{ roundcube_old_version }} && chmod 440 {{ roundcube_web_root }}/config/config.inc.php && chgrp {{ roundcube_user }} {{ roundcube_web_root }}/config/config.inc.php
when:
- roundcube_old_version is defined
- roundcube_upgrade | bool
tags: [ 'roundcube', 'roundcube_upgrade' ]