From 7012a6acfcbecebd617deb5271ef3ff1a8bad20f Mon Sep 17 00:00:00 2001 From: Christian Adams Date: Tue, 29 Aug 2023 11:28:54 -0400 Subject: [PATCH] Modify how pg password is set in postgres pod (#1540) Signed-off-by: Christian M. Adams --- roles/installer/tasks/migrate_data.yml | 2 +- roles/installer/templates/statefulsets/postgres.yaml.j2 | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/installer/tasks/migrate_data.yml b/roles/installer/tasks/migrate_data.yml index 7f999a09a..ae103561f 100644 --- a/roles/installer/tasks/migrate_data.yml +++ b/roles/installer/tasks/migrate_data.yml @@ -76,7 +76,7 @@ trap 'end_keepalive \"$keepalive_file\" \"$keepalive_pid\"' EXIT SIGINT SIGTERM echo keepalive_pid: $keepalive_pid set -e -o pipefail - PGPASSWORD='{{ awx_old_postgres_pass }}' {{ pgdump }} | PGPASSWORD='{{ awx_postgres_pass }}' {{ pg_restore }} + PGPASSWORD=\"$PGPASSWORD_OLD\" {{ pgdump }} | PGPASSWORD=\"$POSTGRES_PASSWORD\" {{ pg_restore }} set +e +o pipefail echo 'Successful' " diff --git a/roles/installer/templates/statefulsets/postgres.yaml.j2 b/roles/installer/templates/statefulsets/postgres.yaml.j2 index 89aa30d92..772410ed4 100644 --- a/roles/installer/templates/statefulsets/postgres.yaml.j2 +++ b/roles/installer/templates/statefulsets/postgres.yaml.j2 @@ -94,6 +94,13 @@ spec: value: '{{ postgres_initdb_args }}' - name: POSTGRES_HOST_AUTH_METHOD value: '{{ postgres_host_auth_method }}' +{% if 'resources' in old_pg_config and old_pg_config['resources'] and 'password' in old_pg_config['resources'][0]['data'] %} + - name: PGPASSWORD_OLD + valueFrom: + secretKeyRef: + name: '{{ old_pg_config['resources'][0]['metadata']['name'] }}' + key: password +{% endif %} ports: - containerPort: {{ awx_postgres_port | default('5432')}} name: postgres-{{ supported_pg_version }}