diff --git a/roles/elasticsearch/tasks/elasticsearch-security.yml b/roles/elasticsearch/tasks/elasticsearch-security.yml index eee28cfa..0fcc3e95 100644 --- a/roles/elasticsearch/tasks/elasticsearch-security.yml +++ b/roles/elasticsearch/tasks/elasticsearch-security.yml @@ -560,6 +560,9 @@ changed_when: false no_log: true when: not elasticsearch_passwords_file.stat.exists | bool + until: es_cluster_status_bootstrap.stdout == "green" + retries: 5 + delay: 10 - name: Fetch Elastic password shell: grep "PASSWORD elastic" {{ elastic_initial_passwords }} | awk {' print $4 '} @@ -580,6 +583,9 @@ no_log: true ignore_errors: "{{ ansible_check_mode }}" when: elasticsearch_passwords_file.stat.exists | bool + until: es_cluster_status.stdout == "green" + retries: 5 + delay: 10 - name: Check for open port 9200/tcp wait_for: @@ -589,20 +595,6 @@ - renew_ca - renew_es_cert -- name: Fail if cluster is not ready yet - fail: - msg: "Elasticsearch cluster is not ready (status: {{ es_cluster_status.stdout }} , yet. Please rerun again later." - when: es_cluster_status.stdout is defined and es_cluster_status.stdout != "green" and groups['elasticsearch'] | length > 1 - tags: - - notest - -- name: Fail if cluster is not ready yet (bootstrap password) - fail: - msg: "Elasticsearch cluster is not ready (status: {{ es_cluster_status_bootstrap.stdout }}), yet. Please rerun again later." - when: es_cluster_status_bootstrap.stdout is defined and es_cluster_status_bootstrap.stdout != "green" and groups['elasticsearch'] | length > 1 - tags: - - notest - - name: Create initial passwords shell: > /usr/share/elasticsearch/bin/elasticsearch-setup-passwords auto -b >