diff --git a/add_pgnode.yml b/add_pgnode.yml index ecbf1dac6..5dff8ccc3 100644 --- a/add_pgnode.yml +++ b/add_pgnode.yml @@ -46,6 +46,12 @@ var: new_nodes tags: always + - name: "Patroni pre-checks" + ansible.builtin.include_role: + name: patroni/pre-checks + when: + - new_node | default(false) | bool + - name: Add a new node to pg_hba.conf on existing cluster nodes ansible.builtin.include_role: name: patroni/config diff --git a/deploy_pgcluster.yml b/deploy_pgcluster.yml index eef011a98..2dfa9a031 100644 --- a/deploy_pgcluster.yml +++ b/deploy_pgcluster.yml @@ -50,6 +50,9 @@ timescale_minimal_pg_version: 12 # if enable_timescale is defined tags: always + - role: patroni/pre-checks + tags: always + tasks: - name: Clean yum cache ansible.builtin.command: yum clean all diff --git a/roles/patroni/pre-checks/tasks/main.yml b/roles/patroni/pre-checks/tasks/main.yml new file mode 100644 index 000000000..7f50bedea --- /dev/null +++ b/roles/patroni/pre-checks/tasks/main.yml @@ -0,0 +1,23 @@ +--- +- block: + - name: "Check all hosts of the etcd cluster" + ansible.builtin.wait_for: + host: "{{ item.host }}" + port: "{{ item.port }}" + state: started + delay: 0 + timeout: 2 + register: patroni_precheck_etcd_port_results + loop: "{{ patroni_etcd_hosts }}" + ignore_errors: true + + - name: "Check if etcd cluster accessible" + run_once: true # noqa run-once + ansible.builtin.fail: + msg: "Please make sure that the etcd cluster nodes are accessible from '{{ inventory_hostname }}'" + when: + - patroni_precheck_etcd_port_results['results'] | rejectattr('failed') | length < 1 + + # TODO: check etcd v3 auth (need gRPC tool) + + when: dcs_exists|bool and dcs_type == 'etcd'