mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-11-06 10:47:32 +01:00
59ccff9bab
When the playbook executes on a remote host (as it usually does), we need to explicitly say `src` is a remote file and not relative to the playbook.
81 lines
2.5 KiB
YAML
81 lines
2.5 KiB
YAML
---
|
|
|
|
# This task is for migrating existing mxisd data when transitioning to the ma1sd fork.
|
|
|
|
- name: Check for existent mxisd data
|
|
stat:
|
|
path: "{{ matrix_base_data_path }}/mxisd"
|
|
register: ma1sd_migrate_mxisd_data_dir_stat
|
|
|
|
- name: Warn if mxisd data detected
|
|
debug:
|
|
msg: >
|
|
You seem to have an existing mxisd data folder in `{{ matrix_base_data_path }}`.
|
|
We are going to migrate it to ma1sd and rename the folder to mxisd.migrated.
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Check existence of old matrix-mxisd service
|
|
stat:
|
|
path: "{{ matrix_systemd_path }}/matrix-mxisd.service"
|
|
register: matrix_mxisd_service_stat
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Ensure matrix-mxisd is stopped
|
|
service:
|
|
name: matrix-mxisd
|
|
state: stopped
|
|
daemon_reload: yes
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists and matrix_mxisd_service_stat.stat.exists"
|
|
|
|
- name: Check existence of matrix-ma1sd service
|
|
stat:
|
|
path: "{{ matrix_systemd_path }}/matrix-ma1sd.service"
|
|
register: matrix_ma1sd_service_stat
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Ensure matrix-ma1sd is stopped
|
|
service:
|
|
name: matrix-ma1sd
|
|
state: stopped
|
|
daemon_reload: yes
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists and matrix_ma1sd_service_stat.stat.exists"
|
|
|
|
- name: Ensure ma1sd data path exist
|
|
file:
|
|
path: "{{ matrix_ma1sd_data_path }}"
|
|
state: directory
|
|
mode: 0750
|
|
owner: "{{ matrix_user_username }}"
|
|
group: "{{ matrix_user_username }}"
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Copy mxisd data files to ma1sd folder
|
|
copy:
|
|
src: "{{ item }}"
|
|
remote_src: true
|
|
dest: "{{ matrix_ma1sd_data_path }}/"
|
|
mode: "preserve"
|
|
owner: "{{ matrix_user_username }}"
|
|
group: "{{ matrix_user_username }}"
|
|
with_items:
|
|
- "{{ matrix_base_data_path }}/mxisd/data/mxisd.db"
|
|
- "{{ matrix_base_data_path }}/mxisd/data/sign.key"
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Rename mxisd folder
|
|
command: "mv {{ matrix_base_data_path }}/mxisd {{ matrix_base_data_path }}/mxisd.migrated"
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Ensure outdated matrix-mxisd.service doesn't exist
|
|
file:
|
|
path: "{{ matrix_systemd_path }}/matrix-mxisd.service"
|
|
state: absent
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
- name: Ensure systemd reloaded after removing outdated matrix-mxisd.service
|
|
service:
|
|
daemon_reload: yes
|
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
|
|
|