From 67ab7e7a1bc4cf799822ec3065b769e77c114ef8 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 13 Jun 2020 07:50:56 +0300 Subject: [PATCH 1/2] Preserve vars.yml on the server for easily restoring Fixes #542 (Github Issues). --- roles/matrix-base/tasks/setup_matrix_base.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/matrix-base/tasks/setup_matrix_base.yml b/roles/matrix-base/tasks/setup_matrix_base.yml index 74d40d1a9..64831f2a6 100644 --- a/roles/matrix-base/tasks/setup_matrix_base.yml +++ b/roles/matrix-base/tasks/setup_matrix_base.yml @@ -10,6 +10,14 @@ with_items: - "{{ matrix_base_data_path }}" +- name: Preserve vars.yml on the server for easily restoring if it gets lost later on + copy: + src: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}/vars.yml" + dest: "{{ matrix_base_data_path }}/vars.yml" + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_groupname }}" + mode: '0660' + # `docker_network` doesn't work as expected when the given network # is a substring of a network that already exists. # From 7729511a84d5a9538d24ed46e9a7beeef24d5c78 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sun, 14 Jun 2020 10:00:22 +0300 Subject: [PATCH 2/2] Make vars.yml snapshotting optional and more configurable Certain people organize their inventory in a different way and we'd like to accommodate them. Related to #542 (Github Issue). --- roles/matrix-base/defaults/main.yml | 6 ++++++ roles/matrix-base/tasks/setup_matrix_base.yml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/matrix-base/defaults/main.yml b/roles/matrix-base/defaults/main.yml index 76c363e4c..8a860b1ea 100644 --- a/roles/matrix-base/defaults/main.yml +++ b/roles/matrix-base/defaults/main.yml @@ -59,6 +59,12 @@ matrix_riot_jitsi_preferredDomain: '' # The Docker network that all services would be put into matrix_docker_network: "matrix" +# Controls whether we'll preserve the vars.yml file on the Matrix server. +# If you have a differently organized inventory, you may wish to disable this feature, +# or to repoint `matrix_vars_yml_snapshotting_src` to the file you'd like to preserve. +matrix_vars_yml_snapshotting_enabled: true +matrix_vars_yml_snapshotting_src: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}/vars.yml" + # Controls whether a `/.well-known/matrix/server` file is generated and used at all. # # If you wish to rely on DNS SRV records only, you can disable this. diff --git a/roles/matrix-base/tasks/setup_matrix_base.yml b/roles/matrix-base/tasks/setup_matrix_base.yml index 64831f2a6..22d330f25 100644 --- a/roles/matrix-base/tasks/setup_matrix_base.yml +++ b/roles/matrix-base/tasks/setup_matrix_base.yml @@ -12,11 +12,12 @@ - name: Preserve vars.yml on the server for easily restoring if it gets lost later on copy: - src: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}/vars.yml" + src: "{{ matrix_vars_yml_snapshotting_src }}" dest: "{{ matrix_base_data_path }}/vars.yml" owner: "{{ matrix_user_username }}" group: "{{ matrix_user_groupname }}" mode: '0660' + when: "matrix_vars_yml_snapshotting_enabled|bool" # `docker_network` doesn't work as expected when the given network # is a substring of a network that already exists.