Skip to content

Commit

Permalink
feat: Check ES health before flushing handlers (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarasg authored Oct 1, 2024
1 parent da6d4e4 commit 919add8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ You can now override the configuration files with your own versions by using the

## Dependency

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

## Testing

Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ es_ssl_verification_mode: "certificate"
es_validate_certs: "yes"
es_delete_unmanaged_file: true
es_delete_unmanaged_native: true

es_healthcheck_auth_scheme: https
es_healthcheck_timeout: 3600
12 changes: 12 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
tags:
- xpack

- name: Wait for cluster status to become green
community.elastic.elastic_cluster_health:
auth_scheme: "{{ es_healthcheck_auth_scheme }}"
login_password: "{{ es_api_basic_auth_password }}"
login_user: "{{ es_api_basic_auth_username }}"
login_hosts: "{{ es_config['discovery.seed_hosts'] }}"
auth_method: http_auth
wait_for: status
to_be: green
timeout: "{{ es_healthcheck_timeout }}"
when: not es_bootstrap | default(false)

- name: flush handlers
meta: flush_handlers

Expand Down

0 comments on commit 919add8

Please sign in to comment.