Skip to content

Commit 919add8

Browse files
authored
feat: Check ES health before flushing handlers (#20)
1 parent da6d4e4 commit 919add8

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ You can now override the configuration files with your own versions by using the
6060

6161
## Dependency
6262

63-
This role uses the json_query filter which [requires jmespath](https://github.com/ansible/ansible/issues/24319) on the local machine.
63+
- json_query filter requires [jmespath](https://github.com/ansible/ansible/issues/24319) on the local machine.
64+
- health check uses [python elasticsearch client](https://elasticsearch-py.readthedocs.io) which must be installed on the target machine.
6465

6566
## Testing
6667

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ es_ssl_verification_mode: "certificate"
7070
es_validate_certs: "yes"
7171
es_delete_unmanaged_file: true
7272
es_delete_unmanaged_native: true
73+
74+
es_healthcheck_auth_scheme: https
75+
es_healthcheck_timeout: 3600

tasks/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
tags:
6060
- xpack
6161

62+
- name: Wait for cluster status to become green
63+
community.elastic.elastic_cluster_health:
64+
auth_scheme: "{{ es_healthcheck_auth_scheme }}"
65+
login_password: "{{ es_api_basic_auth_password }}"
66+
login_user: "{{ es_api_basic_auth_username }}"
67+
login_hosts: "{{ es_config['discovery.seed_hosts'] }}"
68+
auth_method: http_auth
69+
wait_for: status
70+
to_be: green
71+
timeout: "{{ es_healthcheck_timeout }}"
72+
when: not es_bootstrap | default(false)
73+
6274
- name: flush handlers
6375
meta: flush_handlers
6476

0 commit comments

Comments
 (0)