From b7f251ea1635e7e64b96db7a87e0d2016d656ff7 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 27 Jan 2021 15:33:50 -0500 Subject: [PATCH] Retry pgsql bootstrap startup 6 times This will sometimes fail, so retry it several times --- roles/pvc/tasks/patroni/bootstrap.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/pvc/tasks/patroni/bootstrap.yml b/roles/pvc/tasks/patroni/bootstrap.yml index fcebf2a..01395b6 100644 --- a/roles/pvc/tasks/patroni/bootstrap.yml +++ b/roles/pvc/tasks/patroni/bootstrap.yml @@ -11,7 +11,7 @@ command: /usr/share/zookeeper/bin/zkCli.sh rmr /patroni ignore_errors: true -- name: ensure patroni services are enabled and started on this host so it becomes leader +- name: ensure patroni services are enabled and started service: name: "{{ item }}.service" state: started @@ -23,6 +23,13 @@ pause: seconds: 15 +- name: test connecting to cluster + shell: sudo -u postgres psql postgres -c 'select * from pg_stat_activity' || ( service patroni restart && exit 1 ) + register: result + retries: 6 + delay: 5 + until: result.rc == 0 + - block: - name: create user for DNS role postgresql_user: