Skip to content

Commit

Permalink
Change default value for postgres_data_path (#1766)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
---------

Signed-off-by: Seth Foster <[email protected]>
Co-authored-by: Hao Liu <[email protected]>
  • Loading branch information
fosterseth and TheRealHaoLiu authored Mar 13, 2024
1 parent a8acae4 commit 154b801
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion roles/installer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions roles/installer/tasks/database_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 154b801

Please sign in to comment.