ansible-docker-mailcow/roles/mailcow-ansiblerole/tasks/main.yml
Jesko Anschütz d563801458 initial
2025-03-20 10:39:09 +01:00

73 lines
1.7 KiB
YAML
Executable file

---
- name: Install required apt packages
become: yes
apt:
name: git
state: present
- name: Check if mailcow installation directory exists
become: yes
stat:
path: "{{ mailcow__install_path }}"
register: mailcow_installed
- name: Clone mailcow git repo
become: yes
git:
repo: "{{ mailcow__git_repo }}"
version: "{{ mailcow__git_version }}"
umask: '022'
update: false
dest: "{{ mailcow__install_path }}"
when: not mailcow_installed.stat.exists
- name: Generate mailcow.conf file
shell: |
umask 0022
./generate_config.sh
environment:
MAILCOW_HOSTNAME: "{{ mailcow__hostname }}"
MAILCOW_TZ: "{{ mailcow__timezone }}"
MAILCOW_BRANCH: "{{ mailcow__git_version }}"
args:
executable: /bin/bash
chdir: "{{ mailcow__install_path }}"
creates: mailcow.conf
tags:
- skip_ansible_lint
- name: Template settings for mailcow.conf
import_tasks: mailcowconf.yml
- name: Configure Rspamd
import_tasks: rspamd.yml
- name: Migrate NGINX Redirect
import_tasks: nginx.yml
- name: Copy vars.local.inc.php
become: yes
template:
src: vars.local.inc.php.j2
dest: "{{ mailcow__install_path }}/data/web/inc/vars.local.inc.php"
- name: Check if mailcow containers are running
become: yes
community.docker.docker_container_info:
name: "{{ mailcow__docker_compose_project_name }}-nginx-mailcow-1"
register: mailcow_running
- name: Start mailcow container stack
become: yes
shell: |
{{ mailcow__compose_command }} --project-name {{ mailcow__docker_compose_project_name }} up -d
args:
chdir: "{{ mailcow__install_path }}"
when: not mailcow_running.exists
- name: Update mailcow
include_tasks: update.yml
when:
- mailcow_running.exists
- mailcow__install_updates