From 154b801cfcf0683d0b5549460f19a5b9e0427360 Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Wed, 13 Mar 2024 16:17:49 -0400 Subject: [PATCH] Change default value for postgres_data_path (#1766) * Change default value for postgres_data_path /var/lib/postgresql/data/pgdata to /var/lib/pgsql/data/pgdata postgres 15 uses a different location for postgres data directory. Fixes issue were database was not being written to the mounted in volume, and if the postgres container restarted, data would be lost. Signed-off-by: Seth Foster --------- Signed-off-by: Seth Foster Co-authored-by: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> --- roles/installer/defaults/main.yml | 2 +- roles/installer/tasks/database_configuration.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 096dc96b0..cd58f5efb 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -401,7 +401,7 @@ postgres_init_container_resource_requirements: memory: 64Mi # Assign a preexisting priority class to the postgres pod postgres_priority_class: '' -postgres_data_path: '/var/lib/postgresql/data/pgdata' +postgres_data_path: '/var/lib/pgsql/data/pgdata' # Persistence to the AWX project data folder # Whether or not the /var/lib/projects directory will be persistent diff --git a/roles/installer/tasks/database_configuration.yml b/roles/installer/tasks/database_configuration.yml index ee2d952e1..8165a1fb8 100644 --- a/roles/installer/tasks/database_configuration.yml +++ b/roles/installer/tasks/database_configuration.yml @@ -156,17 +156,17 @@ - name: Check if postgres pod is running an older version block: - - name: Set path to PG_VERSION file for given container image - set_fact: - path_to_pg_version: '{{ postgres_data_path }}/PG_VERSION' - - name: Get old PostgreSQL version k8s_exec: namespace: "{{ ansible_operator_meta.namespace }}" pod: "{{ old_postgres_pod['metadata']['name'] }}" command: | bash -c """ - cat {{ path_to_pg_version }} + if [ -f "{{ postgres_data_path }}/PG_VERSION" ]; then + cat "{{ postgres_data_path }}/PG_VERSION" + elif [ -f '/var/lib/postgresql/data/pgdata/PG_VERSION' ]; then + cat '/var/lib/postgresql/data/pgdata/PG_VERSION' + fi """ register: _old_pg_version