From fbd5803f10f4d4c0faf5546a407b8f0387068a2d Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Tue, 7 Dec 2021 17:42:55 -0500 Subject: [PATCH] Wait for Postgres to initialize before starting containers --- roles/installer/tasks/database_configuration.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/roles/installer/tasks/database_configuration.yml b/roles/installer/tasks/database_configuration.yml index 9a09eae9..46f43f2f 100644 --- a/roles/installer/tasks/database_configuration.yml +++ b/roles/installer/tasks/database_configuration.yml @@ -138,6 +138,20 @@ awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}" no_log: true +- name: Wait for Database to initialize + k8s_info: + kind: Pod + namespace: '{{ ansible_operator_meta.namespace }}' + name: '{{ ansible_operator_meta.name }}-postgres-0' # using name to keep compatibility + field_selectors: + - status.phase=Running + register: postgres_pod + until: + - "postgres_pod['resources'] | length" + - "postgres_pod['resources'][0]['status']['phase'] == 'Running'" + delay: 5 + retries: 60 + - name: Look up details for this deployment k8s_info: api_version: "{{ api_version }}"