Fix mxisd -> ma1sd migration for older versions of Ansible
This commit is contained in:
parent
c2d0304eb1
commit
c3efd2966f
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
- name: Check for existent mxisd data
|
- name: Check for existent mxisd data
|
||||||
stat:
|
stat:
|
||||||
path: "{{ matrix_base_data_path }}/mxisd"
|
path: "{{ matrix_base_data_path }}/mxisd/data"
|
||||||
register: ma1sd_migrate_mxisd_data_dir_stat
|
register: ma1sd_migrate_mxisd_data_dir_stat
|
||||||
|
|
||||||
- name: Warn if mxisd data detected
|
- name: Warn if mxisd data detected
|
||||||
debug:
|
debug:
|
||||||
msg: >
|
msg: >
|
||||||
You seem to have an existing mxisd data folder in `{{ matrix_base_data_path }}`.
|
You seem to have an existing mxisd folder in `{{ matrix_base_data_path }}/mxisd`.
|
||||||
We are going to migrate it to ma1sd and rename the folder to mxisd.migrated.
|
We are going to migrate it to ma1sd and rename the folder to mxisd.migrated.
|
||||||
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
||||||
|
|
||||||
@ -40,41 +40,34 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists and matrix_ma1sd_service_stat.stat.exists"
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists and matrix_ma1sd_service_stat.stat.exists"
|
||||||
|
|
||||||
- name: Ensure ma1sd data path exist
|
# We use shell commands for the migration, because the Ansible copy module cannot
|
||||||
file:
|
# recursively copy remote directories (like `/matrix/mxisd/data/sign.key`) in older versions of Ansible.
|
||||||
path: "{{ matrix_ma1sd_data_path }}"
|
- block:
|
||||||
state: directory
|
- name: Copy mxisd data files to ma1sd folder
|
||||||
mode: 0750
|
command: "cp -ar {{ matrix_base_data_path }}/mxisd/data {{ matrix_ma1sd_base_path }}"
|
||||||
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
|
- name: Check existence of mxisd.db file
|
||||||
copy:
|
stat:
|
||||||
src: "{{ item.src }}"
|
path: "{{ matrix_ma1sd_data_path }}/mxisd.db"
|
||||||
remote_src: true
|
register: matrix_ma1sd_mxisd_db_stat
|
||||||
dest: "{{ matrix_ma1sd_data_path }}/{{ item.dst_name }}"
|
|
||||||
mode: "preserve"
|
|
||||||
owner: "{{ matrix_user_username }}"
|
|
||||||
group: "{{ matrix_user_username }}"
|
|
||||||
with_items:
|
|
||||||
- {"src": "{{ matrix_base_data_path }}/mxisd/data/mxisd.db", "dst_name": "ma1sd.db"}
|
|
||||||
- {"src": "{{ matrix_base_data_path }}/mxisd/data/sign.key", "dst_name": "sign.key"}
|
|
||||||
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
|
||||||
|
|
||||||
- name: Rename mxisd folder
|
- name: Rename database (mxisd.db -> ma1sd.db)
|
||||||
command: "mv {{ matrix_base_data_path }}/mxisd {{ matrix_base_data_path }}/mxisd.migrated"
|
command: "mv {{ matrix_ma1sd_data_path }}/mxisd.db {{ matrix_ma1sd_data_path }}/ma1sd.db"
|
||||||
|
when: "matrix_ma1sd_mxisd_db_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"
|
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
||||||
|
|
||||||
- name: Ensure outdated matrix-mxisd.service doesn't exist
|
- name: Ensure outdated matrix-mxisd.service doesn't exist
|
||||||
file:
|
file:
|
||||||
path: "{{ matrix_systemd_path }}/matrix-mxisd.service"
|
path: "{{ matrix_systemd_path }}/matrix-mxisd.service"
|
||||||
state: absent
|
state: absent
|
||||||
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
when: "matrix_ma1sd_service_stat.stat.exists"
|
||||||
|
|
||||||
- name: Ensure systemd reloaded after removing outdated matrix-mxisd.service
|
- name: Ensure systemd reloaded after removing outdated matrix-mxisd.service
|
||||||
service:
|
service:
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
when: "ma1sd_migrate_mxisd_data_dir_stat.stat.exists"
|
when: "matrix_ma1sd_service_stat.stat.exists"
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
# Tasks related to setting up ma1sd
|
# Tasks related to setting up ma1sd
|
||||||
#
|
#
|
||||||
|
|
||||||
- import_tasks: "{{ role_path }}/tasks/migrate_mxisd.yml"
|
|
||||||
when: matrix_ma1sd_enabled|bool
|
|
||||||
|
|
||||||
- name: Ensure ma1sd paths exist
|
- name: Ensure ma1sd paths exist
|
||||||
file:
|
file:
|
||||||
path: "{{ item.path }}"
|
path: "{{ item.path }}"
|
||||||
@ -20,6 +17,9 @@
|
|||||||
- { path: "{{ matrix_ma1sd_docker_src_files_path }}", when: "{{ matrix_ma1sd_container_image_self_build }}"}
|
- { path: "{{ matrix_ma1sd_docker_src_files_path }}", when: "{{ matrix_ma1sd_container_image_self_build }}"}
|
||||||
when: matrix_ma1sd_enabled|bool and item.when
|
when: matrix_ma1sd_enabled|bool and item.when
|
||||||
|
|
||||||
|
- import_tasks: "{{ role_path }}/tasks/migrate_mxisd.yml"
|
||||||
|
when: matrix_ma1sd_enabled|bool
|
||||||
|
|
||||||
- name: Ensure ma1sd image is pulled
|
- name: Ensure ma1sd image is pulled
|
||||||
docker_image:
|
docker_image:
|
||||||
name: "{{ matrix_ma1sd_docker_image }}"
|
name: "{{ matrix_ma1sd_docker_image }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user