2021-02-11 16:18:25 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
- name: Initialize Postgres version determination variables (default to empty)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-04-05 08:22:26 +00:00
|
|
|
matrix_postgres_backup_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION"
|
|
|
|
matrix_postgres_backup_detected_existing: false
|
|
|
|
matrix_postgres_backup_detected_version: ""
|
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: ""
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine existing Postgres version (check PG_VERSION file)
|
2022-07-18 08:22:05 +00:00
|
|
|
ansible.builtin.stat:
|
2021-04-05 08:22:26 +00:00
|
|
|
path: "{{ matrix_postgres_backup_detection_pg_version_path }}"
|
2021-02-11 16:18:25 +00:00
|
|
|
register: result_pg_version_stat
|
|
|
|
|
2022-07-18 07:39:08 +00:00
|
|
|
- ansible.builtin.set_fact:
|
2021-04-05 08:22:26 +00:00
|
|
|
matrix_postgres_backup_detected_existing: true
|
2021-02-11 16:18:25 +00:00
|
|
|
when: "result_pg_version_stat.stat.exists"
|
|
|
|
|
|
|
|
- name: Determine existing Postgres version (read PG_VERSION file)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.slurp:
|
2021-04-05 08:22:26 +00:00
|
|
|
src: "{{ matrix_postgres_backup_detection_pg_version_path }}"
|
2021-02-11 16:18:25 +00:00
|
|
|
register: result_pg_version
|
2022-07-18 08:22:05 +00:00
|
|
|
when: matrix_postgres_backup_detected_existing | bool
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine existing Postgres version (make sense of PG_VERSION file)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2022-07-18 09:28:39 +00:00
|
|
|
matrix_postgres_backup_detected_version: "{{ result_pg_version['content'] | b64decode | replace('\n', '') }}"
|
2022-07-18 08:22:05 +00:00
|
|
|
when: matrix_postgres_backup_detected_existing | bool
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (assume default of latest)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-11 16:18:25 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_latest }}"
|
2021-04-05 08:22:26 +00:00
|
|
|
when: "matrix_postgres_backup_detected_version != ''"
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (use 9.x, if detected)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-11 16:18:25 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v9 }}"
|
2021-04-05 08:22:26 +00:00
|
|
|
when: "matrix_postgres_backup_detected_version.startswith('9.')"
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (use 10.x, if detected)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-11 16:18:25 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v10 }}"
|
2021-04-05 08:22:26 +00:00
|
|
|
when: "matrix_postgres_backup_detected_version == '10' or matrix_postgres_backup_detected_version.startswith('10.')"
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (use 11.x, if detected)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-11 16:18:25 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v11 }}"
|
2021-04-05 08:22:26 +00:00
|
|
|
when: "matrix_postgres_backup_detected_version == '11' or matrix_postgres_backup_detected_version.startswith('11.')"
|
2021-02-11 16:18:25 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (use 12.x, if detected)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-02-11 16:18:25 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v12 }}"
|
2021-04-05 08:22:26 +00:00
|
|
|
when: "matrix_postgres_backup_detected_version == '12' or matrix_postgres_backup_detected_version.startswith('12.')"
|
2021-11-15 07:15:44 +00:00
|
|
|
|
|
|
|
- name: Determine corresponding Docker image to detected version (use 13.x, if detected)
|
2022-07-18 07:39:08 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-11-15 07:15:44 +00:00
|
|
|
matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v13 }}"
|
|
|
|
when: "matrix_postgres_backup_detected_version == '13' or matrix_postgres_backup_detected_version.startswith('13.')"
|