parent
2df993977a
commit
d5f4c17146
@ -0,0 +1,42 @@
|
||||
---
|
||||
|
||||
# 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)
|
||||
set_fact:
|
||||
matrix_backup_borg_postgresql_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION"
|
||||
matrix_backup_borg_postgresql_detected_existing: false
|
||||
matrix_backup_borg_postgresql_detected_version: ""
|
||||
matrix_backup_borg_version: ""
|
||||
|
||||
- name: Determine existing Postgres version (check PG_VERSION file)
|
||||
stat:
|
||||
path: "{{ matrix_backup_borg_postgresql_detection_pg_version_path }}"
|
||||
register: result_pg_version_stat
|
||||
|
||||
- set_fact:
|
||||
matrix_backup_borg_postgresql_detected_existing: true
|
||||
when: "result_pg_version_stat.stat.exists"
|
||||
|
||||
- name: Determine existing Postgres version (read PG_VERSION file)
|
||||
slurp:
|
||||
src: "{{ matrix_backup_borg_postgresql_detection_pg_version_path }}"
|
||||
register: result_pg_version
|
||||
when: matrix_backup_borg_postgresql_detected_existing|bool
|
||||
|
||||
- name: Determine existing Postgres version (make sense of PG_VERSION file)
|
||||
set_fact:
|
||||
matrix_backup_borg_postgresql_detected_version: "{{ result_pg_version['content']|b64decode|replace('\n', '') }}"
|
||||
when: matrix_backup_borg_postgresql_detected_existing|bool
|
||||
|
||||
- name: Determine corresponding Docker image version to detected version
|
||||
set_fact:
|
||||
matrix_backup_borg_version: "{{ matrix_backup_borg_postgresql_detected_version }}"
|
||||
when: "matrix_backup_borg_postgresql_detected_version == '12' or matrix_backup_borg_postgresql_detected_version.startswith('12.') or matrix_backup_borg_postgresql_detected_version == '13' or matrix_backup_borg_postgresql_detected_version.startswith('13.') or matrix_backup_borg_postgresql_detected_version == '14' or matrix_backup_borg_postgresql_detected_version.startswith('14.')"
|
||||
|
||||
- name: Fail if existing Postgres version is not supported by borgmatic docker image
|
||||
fail:
|
||||
msg: >-
|
||||
Your Postgres v{{ matrix_backup_borg_postgresql_detected_version }} is not supported.
|
||||
when: "matrix_backup_borg_version == ''"
|
Loading…
Reference in new issue