Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patroni pre-checks: check etcd cluster accessible #476

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions add_pgnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions deploy_pgcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions roles/patroni/pre-checks/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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'