From 1b55766927137f702e56c34b6d47fd66f744247f Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Mon, 5 Apr 2021 11:32:19 +0300 Subject: [PATCH] Do not redefine matrix-postgres role vars in matrix-postgres-backup Related to https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/868 --- group_vars/matrix_servers | 4 +++- roles/matrix-postgres-backup/defaults/main.yml | 8 +++++--- roles/matrix-postgres-backup/tasks/main.yml | 2 +- .../tasks/setup_postgres_backup.yml | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index bda429dc..06282dfa 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -1786,6 +1786,8 @@ matrix_postgres_backup_connection_port: "{{ matrix_postgres_connection_port }}" matrix_postgres_backup_connection_username: "{{ matrix_postgres_connection_username }}" matrix_postgres_backup_connection_password: "{{ matrix_postgres_connection_password }}" +matrix_postgres_backup_postgres_data_path: "{{ matrix_postgres_data_path if matrix_postgres_enabled else '' }}" + # the default matrix synapse databse is not always part of the matrix_postgres_additional_databases variable thus we have to add it if the default database is used matrix_postgres_backup_databases: | {{ @@ -1800,4 +1802,4 @@ matrix_postgres_backup_databases: | # # /matrix-postgres-backup # -###################################################################### \ No newline at end of file +###################################################################### diff --git a/roles/matrix-postgres-backup/defaults/main.yml b/roles/matrix-postgres-backup/defaults/main.yml index 2f3dbc9e..cc2107f7 100644 --- a/roles/matrix-postgres-backup/defaults/main.yml +++ b/roles/matrix-postgres-backup/defaults/main.yml @@ -14,8 +14,10 @@ matrix_postgres_backup_healthcheck_port: "8080" matrix_postgres_backup_databases: [] matrix_postgres_backup_path: "{{ matrix_base_data_path }}/postgres-backup" -matrix_postgres_base_path: "{{ matrix_base_data_path }}/postgres" -matrix_postgres_data_path: "{{ matrix_postgres_base_path }}/data" +# Specifies where the Postgres data is. +# We use this to autodetect the Postgres version during playbook runtime (by parsing the `PG_VERSION` file contained there). +# You can leave this empty to prevent auto-detection. +matrix_postgres_backup_postgres_data_path: "" matrix_postgres_backup_architecture: amd64 @@ -35,4 +37,4 @@ matrix_postgres_backup_docker_image_latest: "{{ matrix_postgres_backup_docker_im # This variable is assigned at runtime. Overriding its value has no effect. matrix_postgres_backup_docker_image_to_use: '{{ matrix_postgres_backup_docker_image_latest }}' -matrix_postgres_backup_docker_image_force_pull: "{{ matrix_postgres_backup_docker_image_to_use.endswith(':latest') }}" \ No newline at end of file +matrix_postgres_backup_docker_image_force_pull: "{{ matrix_postgres_backup_docker_image_to_use.endswith(':latest') }}" diff --git a/roles/matrix-postgres-backup/tasks/main.yml b/roles/matrix-postgres-backup/tasks/main.yml index f819b8e9..40f4a8bf 100644 --- a/roles/matrix-postgres-backup/tasks/main.yml +++ b/roles/matrix-postgres-backup/tasks/main.yml @@ -14,4 +14,4 @@ when: run_setup|bool tags: - setup-all - - setup-postgres-backup \ No newline at end of file + - setup-postgres-backup diff --git a/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml b/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml index 640d4f14..9761088d 100644 --- a/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml +++ b/roles/matrix-postgres-backup/tasks/setup_postgres_backup.yml @@ -4,14 +4,14 @@ # Tasks related to setting up an internal postgres server # - import_tasks: "{{ role_path }}/tasks/util/detect_existing_postgres_version.yml" - when: matrix_postgres_enabled|bool + when: 'matrix_postgres_backup_enabled|bool and matrix_postgres_backup_postgres_data_path != ""' # If we have found an existing version (installed from before), we use its corresponding Docker image. # If not, we install using the latest Postgres. # # Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`). - set_fact: - matrix_postgres_backup_docker_image_to_use: "{{ matrix_postgres_backup_docker_image_latest if matrix_postgres_backup_detected_version_corresponding_docker_image == '' else matrix_postgres_backup_detected_version_corresponding_docker_image }}" + matrix_postgres_backup_docker_image_to_use: "{{ matrix_postgres_backup_docker_image_latest if matrix_postgres_backup_detected_version_corresponding_docker_image|default('') == '' else matrix_postgres_backup_detected_version_corresponding_docker_image }}" when: matrix_postgres_backup_enabled|bool - name: Ensure postgres backup Docker image is pulled