Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

62 строки
3.4 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. ansible.builtin.set_fact:
  6. matrix_postgres_backup_detection_pg_version_path: "{{ matrix_postgres_data_path }}/PG_VERSION"
  7. matrix_postgres_backup_detected_existing: false
  8. matrix_postgres_backup_detected_version: ""
  9. matrix_postgres_backup_detected_version_corresponding_docker_image: ""
  10. - name: Determine existing Postgres version (check PG_VERSION file)
  11. ansible.builtin.stat:
  12. path: "{{ matrix_postgres_backup_detection_pg_version_path }}"
  13. register: result_pg_version_stat
  14. - ansible.builtin.set_fact:
  15. matrix_postgres_backup_detected_existing: true
  16. when: "result_pg_version_stat.stat.exists"
  17. - name: Determine existing Postgres version (read PG_VERSION file)
  18. ansible.builtin.slurp:
  19. src: "{{ matrix_postgres_backup_detection_pg_version_path }}"
  20. register: result_pg_version
  21. when: matrix_postgres_backup_detected_existing | bool
  22. - name: Determine existing Postgres version (make sense of PG_VERSION file)
  23. ansible.builtin.set_fact:
  24. matrix_postgres_backup_detected_version: "{{ result_pg_version['content'] | b64decode | replace('\n', '') }}"
  25. when: matrix_postgres_backup_detected_existing | bool
  26. - name: Determine corresponding Docker image to detected version (assume default of latest)
  27. ansible.builtin.set_fact:
  28. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_latest }}"
  29. when: "matrix_postgres_backup_detected_version != ''"
  30. - name: Determine corresponding Docker image to detected version (use 9.x, if detected)
  31. ansible.builtin.set_fact:
  32. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v9 }}"
  33. when: "matrix_postgres_backup_detected_version.startswith('9.')"
  34. - name: Determine corresponding Docker image to detected version (use 10.x, if detected)
  35. ansible.builtin.set_fact:
  36. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v10 }}"
  37. when: "matrix_postgres_backup_detected_version == '10' or matrix_postgres_backup_detected_version.startswith('10.')"
  38. - name: Determine corresponding Docker image to detected version (use 11.x, if detected)
  39. ansible.builtin.set_fact:
  40. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v11 }}"
  41. when: "matrix_postgres_backup_detected_version == '11' or matrix_postgres_backup_detected_version.startswith('11.')"
  42. - name: Determine corresponding Docker image to detected version (use 12.x, if detected)
  43. ansible.builtin.set_fact:
  44. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v12 }}"
  45. when: "matrix_postgres_backup_detected_version == '12' or matrix_postgres_backup_detected_version.startswith('12.')"
  46. - name: Determine corresponding Docker image to detected version (use 13.x, if detected)
  47. ansible.builtin.set_fact:
  48. matrix_postgres_backup_detected_version_corresponding_docker_image: "{{ matrix_postgres_backup_docker_image_v13 }}"
  49. when: "matrix_postgres_backup_detected_version == '13' or matrix_postgres_backup_detected_version.startswith('13.')"