From 220d80ac3a40b9ed5541299fbb283e4a1759254d Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 20 Mar 2023 11:06:27 +0200 Subject: [PATCH] Move matrix-aux outside of this playbook --- group_vars/matrix_servers | 20 +++++ playbooks/matrix.yml | 3 +- requirements.yml | 4 + roles/custom/matrix-aux/defaults/main.yml | 81 ------------------- roles/custom/matrix-aux/tasks/main.yml | 9 --- roles/custom/matrix-aux/tasks/setup.yml | 20 ----- .../defaults/main.yml | 3 + .../tasks/validate_config.yml | 16 ++++ 8 files changed, 45 insertions(+), 111 deletions(-) delete mode 100644 roles/custom/matrix-aux/defaults/main.yml delete mode 100644 roles/custom/matrix-aux/tasks/main.yml delete mode 100644 roles/custom/matrix-aux/tasks/setup.yml diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index 45a3990d3..bdc2d1235 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -37,6 +37,26 @@ matrix_playbook_ssl_enabled: "{{ matrix_playbook_ssl_retrieval_method in ['lets- # # ######################################################################## + +######################################################################## +# # +# aux # +# # +######################################################################## + +aux_directory_default_owner: "{{ matrix_user_username }}" +aux_directory_default_group: "{{ matrix_user_groupname }}" + +aux_file_default_owner: "{{ matrix_user_username }}" +aux_file_default_group: "{{ matrix_user_groupname }}" + +######################################################################## +# # +# /aux # +# # +######################################################################## + + ######################################################################## # # # base # diff --git a/playbooks/matrix.yml b/playbooks/matrix.yml index b8964aa54..93e9208f0 100755 --- a/playbooks/matrix.yml +++ b/playbooks/matrix.yml @@ -112,7 +112,8 @@ - galaxy/ntfy - custom/matrix-nginx-proxy - custom/matrix-coturn - - custom/matrix-aux + + - role: galaxy/aux - role: galaxy/com.devture.ansible.role.postgres_backup diff --git a/requirements.yml b/requirements.yml index 85b396b4f..ffcd86afe 100644 --- a/requirements.yml +++ b/requirements.yml @@ -59,3 +59,7 @@ - src: git+https://github.com/devture/com.devture.ansible.role.traefik_certs_dumper.git version: v2.8.1-0 + +- src: git+https://github.com/mother-of-all-self-hosting/ansible-role-aux.git + name: aux + version: v1.0.0-0 diff --git a/roles/custom/matrix-aux/defaults/main.yml b/roles/custom/matrix-aux/defaults/main.yml deleted file mode 100644 index 4c1f88796..000000000 --- a/roles/custom/matrix-aux/defaults/main.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- - -# matrix-aux is a role that manages auxiliary files and directories on your Matrix server. -# -# Certain components (like matrix-synapse, etc.) may sometimes require additional templates (email templates, privacy policies, etc.). -# This role allows such files to be managed by the playbook. -# -# Note that files and directories created via this role are not automatically made available for containers to use. -# If you use this role to put files in a directory that's already mounted into a container, -# you can access the files without additional work. -# Otherwise, you'd need to mount the file/directory to the container that needs it. -# Roles usually provide a `matrix_*_additional_volumes` or `matrix_*_container_extra_arguments` variable -# that you can use to mount an additional volume. - -# The default permission mode when creating directories using `matrix_aux_directory_definitions` -matrix_aux_directory_default_mode: '0750' - -# Holds a list of directories to create on the server. -# -# By default, directories are: -# - created with permissions as specified in `matrix_aux_directory_default_mode` -# - owned by the `matrix_user_username` user and `matrix_user_groupname` group (usually `matrix:matrix`) -# -# Example: -# -# matrix_aux_directory_definitions: -# - dest: /matrix/aux -# -# - dest: /matrix/another -# mode: '0700' -# owner: 'some-user' -# group: 'some-group' -matrix_aux_directory_definitions: [] - -# The default permission mode when creating directories using `matrix_aux_directory_definitions` -matrix_aux_file_default_mode: '0640' - -# Holds a list of files to create on the server. -# -# By default, files are: -# - created with permissions as specified in `matrix_aux_file_default_mode` -# - owned by the `matrix_user_username` user and `matrix_user_groupname` group (usually `matrix:matrix`) -# -# You can define the file content inline (in your `vars.yml` file) or as an external file (see the example below). -# Defining the content inline in `vars.yml` has the benefit of not splitting your configuration into multiple files, -# but rather keeping everything inside `vars.yml` (which also gets backed up on the server in `/matrix/vars.yml`). -# -# Note: parent paths for files must exist. -# If you've defined a file with a destination of `/matrix/some/path/file.txt`, -# then you likely need to add `/matrix/some/path` to `matrix_aux_directory_definitions` as well. -# You don't need to do this for directories that the playbook already creates for you. -# -# Use a `content` key for text content and `src` with a location to a file for binary content. -# The `content` key does not support binary content (see https://github.com/ansible/ansible/issues/11594). -# -# Example: -# -# matrix_aux_file_definitions: -# - dest: "{{ matrix_synapse_config_dir_path }}/something.html" -# content: | -# -# Something -# -# - dest: /matrix/aux/some-other-file.txt -# content: "Something" -# mode: '0600' -# owner: 'some-user' -# group: 'some-group' -# -# - dest: /matrix/aux/yet-another-file.txt -# content: "{{ lookup('template', '/path/to/file.txt.j2') }}" -# mode: '0600' -# owner: 'some-user' -# group: 'some-group' -# -# - dest: /matrix/aux/binary-file.dat -# src: "/path/to/binary.dat" -# mode: '0600' -# owner: 'some-user' -# group: 'some-group' -matrix_aux_file_definitions: [] diff --git a/roles/custom/matrix-aux/tasks/main.yml b/roles/custom/matrix-aux/tasks/main.yml deleted file mode 100644 index 3ae8d1791..000000000 --- a/roles/custom/matrix-aux/tasks/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - -- tags: - - setup-all - - setup-aux-files - - install-all - - install-aux-files - block: - - ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup.yml" diff --git a/roles/custom/matrix-aux/tasks/setup.yml b/roles/custom/matrix-aux/tasks/setup.yml deleted file mode 100644 index eb0adad49..000000000 --- a/roles/custom/matrix-aux/tasks/setup.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- - -- name: Ensure AUX directories are created - ansible.builtin.file: - dest: "{{ item.dest }}" - state: directory - owner: "{{ item.owner | default(matrix_user_username) }}" - group: "{{ item.group | default(matrix_user_groupname) }}" - mode: "{{ item.mode | default(matrix_aux_directory_default_mode) }}" - with_items: "{{ matrix_aux_directory_definitions }}" - -- name: Ensure AUX files are created - ansible.builtin.copy: - src: "{{ item.src if 'src' in item else omit }}" - content: "{{ item.content if 'content' in item else omit }}" - dest: "{{ item.dest }}" - owner: "{{ item.owner | default(matrix_user_username) }}" - group: "{{ item.group | default(matrix_user_groupname) }}" - mode: "{{ item.mode | default(matrix_aux_file_default_mode) }}" - with_items: "{{ matrix_aux_file_definitions }}" diff --git a/roles/custom/matrix_playbook_migration/defaults/main.yml b/roles/custom/matrix_playbook_migration/defaults/main.yml index dbc3b3b86..ee051193a 100644 --- a/roles/custom/matrix_playbook_migration/defaults/main.yml +++ b/roles/custom/matrix_playbook_migration/defaults/main.yml @@ -20,3 +20,6 @@ matrix_playbook_migration_matrix_redis_migration_validation_enabled: true # Controls if (`matrix_etherpad` -> `etherpad`) validation will run. matrix_playbook_migration_matrix_etherpad_migration_validation_enabled: true + +# Controls if (`matrix_aux` -> `aux`) validation will run. +matrix_playbook_migration_matrix_aux_migration_validation_enabled: true diff --git a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml index d8fe16839..87292cdb7 100644 --- a/roles/custom/matrix_playbook_migration/tasks/validate_config.yml +++ b/roles/custom/matrix_playbook_migration/tasks/validate_config.yml @@ -157,3 +157,19 @@ Please change your configuration (vars.yml) to rename all variables (`matrix_etherpad_` -> `etherpad_`). We found usage of the following variables: {{ matrix_playbook_migration_etherpad_migration_vars.keys() | join(', ') }} when: "matrix_playbook_migration_etherpad_migration_vars | length > 0" + +- when: matrix_playbook_migration_matrix_aux_migration_validation_enabled | bool + block: + - ansible.builtin.set_fact: + matrix_playbook_migration_aux_migration_vars: |- + {{ vars | dict2items | selectattr('key', 'match', 'matrix_aux_.*') | list | items2dict }} + + - name: (Deprecation) Catch and report matrix_aux variables + ansible.builtin.fail: + msg: >- + The matrix-aux role that used to be part of this playbook has been replaced by https://github.com/mother-of-all-self-hosting/ansible-role-aux. + The new role is compatible with the old one, but uses different names for its variables. + Please change your configuration (vars.yml) to rename all variables (`matrix_aux_` -> `aux_`). + We found usage of the following variables: {{ matrix_playbook_migration_aux_migration_vars.keys() | join(', ') }} + when: "matrix_playbook_migration_aux_migration_vars | length > 0" +