Import tasks from other roles in a better way
One that doesn't trip up ansible-lint, causing `load-failure` errors.
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
|
||||
# This utility aims to determine if there is some existing Postgres version in use or not.
|
||||
# If there is, it also tries to detect the Docker image that corresponds to that version.
|
||||
#
|
||||
# This utility is intentionally not in `tasks/util`, because if it were, it wouldn't be possible
|
||||
# to include it in other roles via the import_role module: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_role_module.html
|
||||
|
||||
- name: Initialize Postgres version determination variables (default to empty)
|
||||
ansible.builtin.set_fact:
|
@ -56,7 +56,7 @@
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
|
||||
- ansible.builtin.import_tasks: tasks/util/detect_existing_postgres_version.yml
|
||||
- ansible.builtin.import_tasks: tasks/detect_existing_postgres_version.yml
|
||||
|
||||
- name: Abort, if no existing Postgres version detected
|
||||
ansible.builtin.fail:
|
||||
|
@ -135,9 +135,9 @@
|
||||
changed_when: matrix_postgres_migrate_db_to_postgres_import_result.rc == 0
|
||||
|
||||
- block:
|
||||
# We can't use `{{ role_path }}` here, neither with `import_tasks`, nor with `include_tasks`,
|
||||
# because it refers to the role that included this util, and not to the role this file belongs to.
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/../matrix-postgres/tasks/util/detect_existing_postgres_version.yml"
|
||||
- ansible.builtin.import_role:
|
||||
name: matrix-postgres
|
||||
tasks_from: detect_existing_postgres_version
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
matrix_postgres_docker_image_to_use: "{{ matrix_postgres_docker_image_latest if matrix_postgres_detected_version_corresponding_docker_image == '' else matrix_postgres_detected_version_corresponding_docker_image }}"
|
@ -9,6 +9,9 @@
|
||||
#
|
||||
# For this reason, we store the Postgres data in `/matrix/postgres/data` and need to relocate any installations
|
||||
# which still store it in the parent directory (`/matrix/postgres`).
|
||||
#
|
||||
# This utility is intentionally not in `tasks/util`, because if it were, it wouldn't be possible
|
||||
# to include it in other roles via the import_role module: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_role_module.html
|
||||
|
||||
- name: Check if old Postgres data directory is used
|
||||
ansible.builtin.stat:
|
||||
|
@ -35,7 +35,7 @@
|
||||
delegate_to: 127.0.0.1
|
||||
become: false
|
||||
|
||||
- ansible.builtin.import_tasks: tasks/util/detect_existing_postgres_version.yml
|
||||
- ansible.builtin.import_tasks: tasks/detect_existing_postgres_version.yml
|
||||
|
||||
- name: Abort, if no existing Postgres version detected
|
||||
ansible.builtin.fail:
|
||||
|
@ -7,7 +7,7 @@
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/migrate_postgres_data_directory.yml"
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/util/detect_existing_postgres_version.yml"
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/detect_existing_postgres_version.yml"
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
# If we have found an existing version (installed from before), we use its corresponding Docker image.
|
||||
|
@ -40,7 +40,7 @@
|
||||
msg: "Detected that a left-over {{ postgres_auto_upgrade_backup_data_path }} exists. You should rename it to {{ matrix_postgres_data_path }} if the previous upgrade went wrong, or delete it if it went well."
|
||||
when: "result_auto_upgrade_path.stat.exists"
|
||||
|
||||
- ansible.builtin.import_tasks: tasks/util/detect_existing_postgres_version.yml
|
||||
- ansible.builtin.import_tasks: tasks/detect_existing_postgres_version.yml
|
||||
|
||||
- name: Abort, if no existing Postgres version detected
|
||||
ansible.builtin.fail:
|
||||
|
Reference in New Issue
Block a user