You've already forked matrix-docker-ansible-deploy
mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-06-12 22:17:28 +02:00
More ansible-lint fixes
This commit is contained in:
@ -4,11 +4,11 @@
|
||||
# Tasks related to setting up an internal postgres server
|
||||
#
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/migrate_postgres_data_directory.yml"
|
||||
when: matrix_postgres_enabled|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/migrate_postgres_data_directory.yml"
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- import_tasks: "{{ role_path }}/tasks/util/detect_existing_postgres_version.yml"
|
||||
when: matrix_postgres_enabled|bool
|
||||
- ansible.builtin.import_tasks: "{{ role_path }}/tasks/util/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.
|
||||
# If not, we install using the latest Postgres.
|
||||
@ -16,24 +16,24 @@
|
||||
# Upgrading is supposed to be performed separately and explicitly (see `upgrade_postgres.yml`).
|
||||
- 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 }}"
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Abort if on an unsupported Postgres version
|
||||
ansible.builtin.fail:
|
||||
msg: "You're on Postgres {{ matrix_postgres_detected_version }}, which is no longer supported. To upgrade, see docs/maintenance-postgres.md"
|
||||
when: "matrix_postgres_enabled|bool and matrix_postgres_detected_version.startswith('9.')"
|
||||
when: "matrix_postgres_enabled | bool and matrix_postgres_detected_version.startswith('9.')"
|
||||
|
||||
- name: Inject warning if on an old version of Postgres
|
||||
ansible.builtin.set_fact:
|
||||
matrix_playbook_runtime_results: |
|
||||
{{
|
||||
matrix_playbook_runtime_results|default([])
|
||||
matrix_playbook_runtime_results | default([])
|
||||
+
|
||||
[
|
||||
"NOTE: Your setup is on an old Postgres version ({{ matrix_postgres_docker_image_to_use }}), while {{ matrix_postgres_docker_image_latest }} is supported. You can upgrade using --tags=upgrade-postgres"
|
||||
]
|
||||
}}
|
||||
when: "matrix_postgres_enabled|bool and matrix_postgres_docker_image_to_use != matrix_postgres_docker_image_latest"
|
||||
when: "matrix_postgres_enabled | bool and matrix_postgres_docker_image_to_use != matrix_postgres_docker_image_latest"
|
||||
|
||||
# Even if we don't run the internal server, we still need this for running the CLI
|
||||
- name: Ensure postgres Docker image is pulled
|
||||
@ -42,7 +42,7 @@
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_postgres_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
||||
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_postgres_docker_image_force_pull }}"
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
register: result
|
||||
retries: "{{ matrix_container_retries_count }}"
|
||||
delay: "{{ matrix_container_retries_delay }}"
|
||||
@ -58,7 +58,7 @@
|
||||
with_items:
|
||||
- "{{ matrix_postgres_base_path }}"
|
||||
- "{{ matrix_postgres_data_path }}"
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
# We do this as a separate task, because:
|
||||
# - we'd like to do it for the data path only, not for the base path (which contains root-owned environment variable files we'd like to leave as-is)
|
||||
@ -70,7 +70,7 @@
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
recurse: true
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure Postgres environment variables file created
|
||||
ansible.builtin.template:
|
||||
@ -82,41 +82,41 @@
|
||||
with_items:
|
||||
- "env-postgres-psql"
|
||||
- "env-postgres-server"
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure matrix-postgres-cli script created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-cli.j2"
|
||||
dest: "{{ matrix_local_bin_path }}/matrix-postgres-cli"
|
||||
mode: 0755
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure matrix-postgres-cli-non-interactive script created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-cli-non-interactive.j2"
|
||||
dest: "{{ matrix_local_bin_path }}/matrix-postgres-cli-non-interactive"
|
||||
mode: 0755
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure matrix-change-user-admin-status script created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/usr-local-bin/matrix-change-user-admin-status.j2"
|
||||
dest: "{{ matrix_local_bin_path }}/matrix-change-user-admin-status"
|
||||
mode: 0755
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: (Migration) Ensure old matrix-make-user-admin script deleted
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_local_bin_path }}/matrix-make-user-admin"
|
||||
state: absent
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure matrix-postgres-update-user-password-hash script created
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/usr-local-bin/matrix-postgres-update-user-password-hash.j2"
|
||||
dest: "{{ matrix_local_bin_path }}/matrix-postgres-update-user-password-hash"
|
||||
mode: 0755
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure matrix-postgres.service installed
|
||||
ansible.builtin.template:
|
||||
@ -124,37 +124,37 @@
|
||||
dest: "{{ matrix_systemd_path }}/matrix-postgres.service"
|
||||
mode: 0644
|
||||
register: matrix_postgres_systemd_service_result
|
||||
when: matrix_postgres_enabled|bool
|
||||
when: matrix_postgres_enabled | bool
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-postgres.service installation
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "matrix_postgres_enabled|bool and matrix_postgres_systemd_service_result.changed"
|
||||
when: "matrix_postgres_enabled | bool and matrix_postgres_systemd_service_result.changed"
|
||||
|
||||
- include_tasks:
|
||||
- ansible.builtin.include_tasks:
|
||||
ansible.builtin.file: "{{ role_path }}/tasks/util/create_additional_databases.yml"
|
||||
apply:
|
||||
tags:
|
||||
- always
|
||||
when: "matrix_postgres_enabled|bool and matrix_postgres_additional_databases|length > 0"
|
||||
when: "matrix_postgres_enabled | bool and matrix_postgres_additional_databases|length > 0"
|
||||
|
||||
- name: Check existence of matrix-postgres backup data path
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_postgres_data_path }}-auto-upgrade-backup"
|
||||
register: matrix_postgres_data_backup_path_stat
|
||||
when: "matrix_postgres_enabled|bool"
|
||||
when: "matrix_postgres_enabled | bool"
|
||||
|
||||
- name: Inject warning if backup data remains
|
||||
ansible.builtin.set_fact:
|
||||
matrix_playbook_runtime_results: |
|
||||
{{
|
||||
matrix_playbook_runtime_results|default([])
|
||||
matrix_playbook_runtime_results | default([])
|
||||
+
|
||||
[
|
||||
"NOTE: You have some Postgres backup data in `{{ matrix_postgres_data_path }}-auto-upgrade-backup`, which was created during the last major Postgres update you ran. If your setup works well after this upgrade, feel free to delete this whole directory."
|
||||
]
|
||||
}}
|
||||
when: "matrix_postgres_enabled|bool and matrix_postgres_data_backup_path_stat.stat.exists"
|
||||
when: "matrix_postgres_enabled | bool and matrix_postgres_data_backup_path_stat.stat.exists"
|
||||
|
||||
|
||||
#
|
||||
@ -162,47 +162,47 @@
|
||||
#
|
||||
|
||||
- name: Check existence of matrix-postgres service
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_systemd_path }}/matrix-postgres.service"
|
||||
register: matrix_postgres_service_stat
|
||||
when: "not matrix_postgres_enabled|bool"
|
||||
when: "not matrix_postgres_enabled | bool"
|
||||
|
||||
- name: Ensure matrix-postgres is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-postgres
|
||||
state: stopped
|
||||
daemon_reload: true
|
||||
when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists"
|
||||
when: "not matrix_postgres_enabled | bool and matrix_postgres_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-postgres.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_systemd_path }}/matrix-postgres.service"
|
||||
state: absent
|
||||
when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists"
|
||||
when: "not matrix_postgres_enabled | bool and matrix_postgres_service_stat.stat.exists"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-postgres.service removal
|
||||
ansible.builtin.service:
|
||||
daemon_reload: true
|
||||
when: "not matrix_postgres_enabled|bool and matrix_postgres_service_stat.stat.exists"
|
||||
when: "not matrix_postgres_enabled | bool and matrix_postgres_service_stat.stat.exists"
|
||||
|
||||
- name: Check existence of matrix-postgres local data path
|
||||
stat:
|
||||
ansible.builtin.stat:
|
||||
path: "{{ matrix_postgres_data_path }}"
|
||||
register: matrix_postgres_data_path_stat
|
||||
when: "not matrix_postgres_enabled|bool"
|
||||
when: "not matrix_postgres_enabled | bool"
|
||||
|
||||
# We just want to notify the user. Deleting data is too destructive.
|
||||
- name: Inject warning if matrix-postgres local data remains
|
||||
ansible.builtin.set_fact:
|
||||
matrix_playbook_runtime_results: |
|
||||
{{
|
||||
matrix_playbook_runtime_results|default([])
|
||||
matrix_playbook_runtime_results | default([])
|
||||
+
|
||||
[
|
||||
"NOTE: You are not using a local PostgreSQL database, but some old data remains from before in `{{ matrix_postgres_data_path }}`. Feel free to delete it."
|
||||
]
|
||||
}}
|
||||
when: "not matrix_postgres_enabled|bool and matrix_postgres_data_path_stat.stat.exists"
|
||||
when: "not matrix_postgres_enabled | bool and matrix_postgres_data_path_stat.stat.exists"
|
||||
|
||||
- name: Remove Postgres scripts
|
||||
ansible.builtin.file:
|
||||
@ -212,4 +212,4 @@
|
||||
- matrix-postgres-cli
|
||||
- matrix-change-user-admin-status
|
||||
- matrix-postgres-update-user-password-hash
|
||||
when: "not matrix_postgres_enabled|bool"
|
||||
when: "not matrix_postgres_enabled | bool"
|
||||
|
Reference in New Issue
Block a user