๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ansible-playbooks/roles/mail/tasks/main.yml

214 lines
4.0 KiB

- name: install dependencies
package:
name:
- php7
- curl
- libgd
- php7-fpm
- aspell-libs
- aspell-en
- aspell-ru
- aspell
- aspell-lang
- gnupg
- name: install php7 dependencies
package:
name:
- php7-dom
- php7-session
- php7-xml
- php7-intl
- php7-json
- php7-pdo
- php7-pdo_mysql
- php7-pdo_pgsql
- php7-mbstring
- php7-openssl
- php7-ctype
- php7-curl
- php7-fileinfo
- php7-exif
- php7-iconv
- php7-gd
- php7-zip
- php7-pspell
- php7-pcntl
- php7-xmlwriter
- php7-tokenizer
- name: create user and group
include_tasks: tasks/create_user.yml
vars:
user:
name: "{{ mail_user }}"
group: "{{ mail_group }}"
dir: "{{ mail_dir }}"
create_home: no
- name: create mail dir
file:
path: "{{ mail_dir }}"
state: directory
mode: 0775
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
- name: create key dir for enigma plugin
file:
path: "{{ mail_dir }}/{{ mail_enigma_subdir }}"
state: directory
mode: 0770
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
- name: template php7 custom config
template:
src: php.j2
dest: /etc/php7/conf.d/50_override.ini
force: yes
mode: 0640
notify: restart php fpm
- name: template fpm custom config
template:
src: fpm.j2
dest: /etc/php7/php-fpm.d/roundcube.conf
force: yes
mode: 0640
notify: restart php fpm
- name: delete www fpm config
file:
path: /etc/php7/php-fpm.d/www.conf
state: absent
- name: install and configure nginx
include_role:
name: nginx
vars:
nginx:
servers:
- conf: nginx_server
certs: true
group: "{{ mail_group }}"
fastcgi: yes
- name: get latest version of roundcube
include_tasks: get_lastversion.yml
vars:
package:
name: roundcube/roundcubemail
location: github
assets: true
asset_filter: 'complete.tar.gz$'
file: "{{ mail_dir }}/last_version"
extract: "{{ mail_dir }}"
user: "{{ mail_user }}"
group: "{{ mail_group }}"
notify: restart php fpm
strip_first_dir: yes
- name: ensure roundcube logs/temp directories are writable
file:
path: "{{ mail_dir }}/{{ item }}"
mode: 0775
state: directory
loop:
- logs
- temp
- name: download mime types
get_url:
url: https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
dest: "{{ mail_dir }}/config/{{ mail_mime_types_file }}"
mode: 0440
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
notify: restart php fpm
- name: create custom directory
file:
path: "{{ mail_dir }}/public_html/custom"
mode: 0775
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
state: directory
- name: upload files to custom directory
copy:
src: "{{ item }}"
dest: "{{ mail_dir }}/public_html/custom/{{ item }}"
mode: 0444
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
loop:
- favicon.ico
- logo.png
- name: template roundcube config
template:
src: config.j2
dest: "{{ mail_dir }}/config/config.inc.php"
force: yes
mode: 0660
owner: "{{ mail_user }}"
group: "{{ mail_group }}"
notify: restart php fpm
- name: delete sample config
file:
path: "{{ mail_dir }}/config/config.inc.php.sample"
state: absent
- name: setup database
include_tasks: db.yml
- name: install plugins
include_tasks: plugin.yml
loop: "{{ mail_plugins }}"
- name: add cleandb cron job
cron:
name: roundcube database cleanup
job: "{{ mail_dir }}/bin/cleandb.sh > /dev/null"
hour: "5"
minute: "0"
user: "{{ mail_user }}"
- name: add directories to backup plan
include_role:
name: backup
vars:
function: add
backup_items:
- "{{ mail_dir }}"
- name: enable and start php-fpm7
service:
name: php-fpm7
state: started
enabled: yes