# Ansible Playbook Hangs on " Wait for elasticsearch to startup "

**URL:** <https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610>\
**Category:** Elasticsearch\
**Created:** [March 14, 2017, 10:16pm UTC](https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610 "2017-03-14T22:16:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Traiano\_Welcome](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Traiano\_Welcome](https://discuss.elastic.co/u/Traiano_Welcome)\
**Post date:** [March 14, 2017, 10:16pm UTC](https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610/1 "2017-03-14T22:16:34Z")

</div>

Hi, I'm trying to deploy a 3 node elasticsearch cluster to aws EC2 using the role here:

> **[elastic/ansible-elasticsearch](https://github.com/elastic/ansible-elasticsearch)**
>
> ansible-elasticsearch - Ansible playbook for Elasticsearch

Ansible runs the playbook with no error, until it hangs for minutes on this step:

"TASK [elasticsearch : Wait for elasticsearch to startup delay=5, host={{es\_api\_host}}, port={{es\_api\_port}}, connect\_timeout=1] \*\*\*"

I can ssh in, but find that elasticsearch is not running.

Here is the tail end of that failure:

* * *

## TASK [elasticsearch : command \_raw\_params=/bin/true] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Copy role\_mapping.yml File for Instance src=security/role\_mapping.yml.j2, force=yes, mode=0644, dest={{conf\_dir}}/x-pack/role\_mapping.yml, group={{ es\_group }}, owner={{ es\_user }}] \*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Copy message auth key to elasticsearch src={{ es\_message\_auth\_file }}, force=yes, mode=0600, dest={{conf\_dir}}/x-pack/system\_key, group={{ es\_group }}, owner={{ es\_user }}] \*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Ensure security conf directory exists owner={{ es\_user }}, path={{ conf\_dir }}/security, state=directory, group={{ es\_group }}] \*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Set Plugin Directory Permissions owner={{ es\_user }}, path={{ es\_home }}/plugins, state=directory, group={{ es\_group }}, recurse=yes] \*\*\* ok: [10.16.8.111] TASK [elasticsearch : file owner={{ es\_user }}, path=/etc/elasticsearch/templates, state=directory, group={{ es\_group }}] \*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Copy default templates to elasticsearch dest=/etc/elasticsearch/, src=templates, group={{ es\_group }}, owner={{ es\_user }}] \*\*\* skipping: [10.16.8.111] TASK [elasticsearch : Copy templates to elasticsearch dest=/etc/elasticsearch/templates, src={{ item }}, group={{ es\_group }}, owner={{ es\_user }}] \*\*\* TASK [elasticsearch : Wait for elasticsearch to startup delay=5, host={{es\_api\_host}}, port={{es\_api\_port}}, connect\_timeout=1] \*\*\*

NOTES:

- My playbook is pretty much identical to the example provided there as well, and I've made 0 modifications to the role.
- I can ssh into the instances after the failure, so connectivity is not an issue. Elasticsearch is not running.

The playbook is as follows:

* * *

- hosts: es\_master\_nodes  
roles:

- hosts: es\_data\_nodes  
roles:

- hosts: es\_data\_nodes  
roles:

* * *

---

<div class="post-metadata">

**Author:** ![Traiano\_Welcome](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Traiano\_Welcome](https://discuss.elastic.co/u/Traiano_Welcome)\
**Post date:** [March 15, 2017, 5:17am UTC](https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610/2 "2017-03-15T05:17:28Z")

</div>

Running ansible with -vvv for verbose output:

* * *

ASK [elasticsearch : Copy templates to elasticsearch dest=/etc/elasticsearch/templates, src={{ item }}, group={{ es\_group }}, owner={{ es\_user }}] \*\*\*  
task path: /Users/welcome/GitLab/skunkworks/elasticsearch/playbooks/roles/elasticsearch/tasks/elasticsearch-templates.yml:10

TASK [elasticsearch : Wait for elasticsearch to startup delay=5, host={{es\_api\_host}}, port={{es\_api\_port}}, connect\_timeout=1] \*\*\*  
task path: /Users/welcome/GitLab/skunkworks/elasticsearch/playbooks/roles/elasticsearch/tasks/main.yml:47  
Using module file /usr/local/lib/python2.7/site-packages/ansible/modules/core/utilities/logic/wait\_for.py  
\<10.16.8.111\> ESTABLISH SSH CONNECTION FOR USER: centos  
\<10.16.8.111\> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/Users/welcome/.ssh/eu.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 -o ControlPath=/Users/welcome/.ansible/cp/ansible-ssh-%h-%p-%r 10.16.8.111 '/bin/sh -c '"'"'( umask 77 && mkdir -p "`echo ~/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040`" && echo ansible-tmp-1489554497.92-236839198736040="`echo ~/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040`" ) && sleep 0'"'"''  
\<10.16.8.111\> PUT /var/folders/ys/ykfsqtz54xn6k9vgfwdhckkw0000gp/T/tmpkJbVnZ TO /home/centos/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040/wait\_for.py  
\<10.16.8.111\> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/Users/welcome/.ssh/eu.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 -o ControlPath=/Users/welcome/.ansible/cp/ansible-ssh-%h-%p-%r '[10.16.8.111]'  
\<10.16.8.111\> ESTABLISH SSH CONNECTION FOR USER: centos\<10.16.8.111\> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/Users/welcome/.ssh/eu.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 -o ControlPath=/Users/welcome/.ansible/cp/ansible-ssh-%h-%p-%r 10.16.8.111 '/bin/sh -c '"'"'chmod u+x /home/centos/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040/ /home/centos/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040/wait\_for.py && sleep 0'"'"''  
\<10.16.8.111\> ESTABLISH SSH CONNECTION FOR USER: centos  
\<10.16.8.111\> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/Users/welcome/.ssh/eu.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=10 -o ControlPath=/Users/welcome/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.16.8.111 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-hsmfdhfanfkjqnbmoxjihrtuhbbvegsg; /usr/bin/python /home/centos/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040/wait\_for.py; rm -rf "/home/centos/.ansible/tmp/ansible-tmp-1489554497.92-236839198736040/" \> /dev/null 2\>&1'"'"'"'"'"'"'"'"' && sleep 0'"'"''

* * *

---

<div class="post-metadata">

**Author:** ![Traiano\_Welcome](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Traiano\_Welcome](https://discuss.elastic.co/u/Traiano_Welcome)\
**Post date:** [March 15, 2017, 12:29pm UTC](https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610/3 "2017-03-15T12:29:44Z")

</div>

Found the issue here. The ansible role does not seem to enable the elasticsearch startp service in systemd. I added an ansible bloc to do this in the role definition.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 12, 2017, 12:29pm UTC](https://discuss.elastic.co/t/ansible-playbook-hangs-on-wait-for-elasticsearch-to-startup/78610/4 "2017-04-12T12:29:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
