Files
operating-automation/playbooks/managed-mailcow/update-mailcow.yaml.old
Ansible Servercow 7d26d8f534 move files
2024-11-19 16:10:59 +01:00

42 lines
1.2 KiB
YAML

---
- name: Update mailcow stacks
hosts: all
vars:
github_mailcow_ver: "2024-08a"
mailcow_search_paths:
- /opt
- /data
- /root
tasks:
- name: Find mailcow-dockerized directory
ansible.builtin.find:
file_type: directory
paths: "{{ mailcow_search_paths }}"
patterns: mailcow-dockerized
recurse: yes
register: mailcow_dir_result
ignore_errors: true
- name: 'DEBUG: Show file paths'
debug:
msg: "{{ mailcow_dir_result.files[0].path }}"
when: mailcow_dir_result is defined
- name: Check if mailcow.conf exists
ansible.builtin.stat:
path: "{{ mailcow_dir_result.files[0].path }}/mailcow.conf"
register: mailcow_conf
when: mailcow_dir_result is defined
- name: Check mailcow Version
ansible.builtin.shell: |
cd {{ mailcow_dir_result.files[0].path }}/data/web/inc
grep -oP '\$MAILCOW_GIT_VERSION="\K[^"]+' app_info.inc.php
register: local_mailcow_version
when: mailcow_conf.stat.exists
- name: Update mailcow
shell: "cd {{ mailcow_dir_result.files[0].path }} && git fetch && git checkout origin/master update.sh && ./update.sh --force"
when: local_mailcow_version.stdout != github_mailcow_ver and mailcow_conf.stat.exists