From af07cb2fe7e756c4791fca58c0e7b96b58ad9bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lisowski?= Date: Wed, 29 Nov 2023 15:55:32 +0100 Subject: [PATCH] Better handling of the service in stopped state * Prevented waiting for Elasticsearch when `elasticsearch_service_state` is set to `stopped`. * Avoided triggering 'restart elasticsearch' handler under the same condition. Reasoning: Encountered a need to configure security features mandatory for Elasticsearch 8.x. Initial attempts to configure pre-installation were unsuccessful, as these settings require Elasticsearch to be installed first. Thus, opted for post-installation configuration. This necessitated the ability to install and configure Elasticsearch without starting the service. Note: Security settings required by default in Elasticsearch 8.x ideally should be incorporated into the role itself. Plan to explore adding this support to the existing role when possible. --- handlers/main.yml | 1 + tasks/main.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/handlers/main.yml b/handlers/main.yml index a4c1162..93a3560 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ --- - name: restart elasticsearch service: name=elasticsearch state=restarted + when: elasticsearch_service_state == 'started' diff --git a/tasks/main.yml b/tasks/main.yml index 1926fe7..61870c2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,3 +52,4 @@ port: "{{ elasticsearch_http_port }}" delay: 3 timeout: 300 + when: elasticsearch_service_state == 'started'