Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
2.1 KiB

  1. ---
  2. # This utility aims to determine if there is some existing Postgres version in use or not.
  3. # If there is, it also tries to detect the Docker image that corresponds to that version.
  4. - name: Initialize Postgres version determination variables (default to empty)
  5. set_fact:
  6. matrix_backup_borg_postgresql_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION"
  7. matrix_backup_borg_postgresql_detected_existing: false
  8. matrix_backup_borg_postgresql_detected_version: ""
  9. matrix_backup_borg_version: ""
  10. - name: Determine existing Postgres version (check PG_VERSION file)
  11. stat:
  12. path: "{{ matrix_backup_borg_postgresql_detection_pg_version_path }}"
  13. register: result_pg_version_stat
  14. - set_fact:
  15. matrix_backup_borg_postgresql_detected_existing: true
  16. when: "result_pg_version_stat.stat.exists"
  17. - name: Determine existing Postgres version (read PG_VERSION file)
  18. slurp:
  19. src: "{{ matrix_backup_borg_postgresql_detection_pg_version_path }}"
  20. register: result_pg_version
  21. when: matrix_backup_borg_postgresql_detected_existing|bool
  22. - name: Determine existing Postgres version (make sense of PG_VERSION file)
  23. set_fact:
  24. matrix_backup_borg_postgresql_detected_version: "{{ result_pg_version['content']|b64decode|replace('\n', '') }}"
  25. when: matrix_backup_borg_postgresql_detected_existing|bool
  26. - name: Determine corresponding Docker image version to detected version
  27. set_fact:
  28. matrix_backup_borg_version: "{{ matrix_backup_borg_postgresql_detected_version }}"
  29. 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.')"
  30. - name: Fail if existing Postgres version is not supported by borgmatic docker image
  31. fail:
  32. msg: >-
  33. Your Postgres v{{ matrix_backup_borg_postgresql_detected_version }} is not supported.
  34. when: "matrix_backup_borg_version == ''"