Elasticsearch restart task hangs up in Ansible Playbook

I am using ansible playbook to install elasticsearch and elasticsearch plugin. after successfully installation of Elasticsearch I written one ansible task to Restart Elasticsearch. Its restarting elasticsearch but ansible playbook hang up in this task. My ansible task is:

`

  • name: “Ensure Elasticsearch is Running”
    service: name=elasticsearch state=restarted

`

I also tried with shell: sudo service elasticsearch restart but no luck.

Elasticsearch Version : 1.3.0
Ansible Version : 1.5.5

Verbose Output for the task is :

`
<app101.host.com> ESTABLISH CONNECTION FOR USER: prod on PORT 22 TO app101.host.com
<app101.host.com> REMOTE_MODULE service name=elasticsearch state=restarted
<app101.host.com> EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310
&& chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310 && echo $HOME/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310’
<app101.host.com> PUT /tmp/tmpjIMUkF TO /home/prod/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310/service
<app101.host.com> EXEC /bin/sh -c ‘sudo -k && sudo -H -S -p “[sudo via ansible, key=yeztwzmmsgyvjjqmmunnvtbopcplrbso]
password: " -u root /bin/sh -c '”’“‘echo SUDO-SUCCESS-yeztwzmmsgyvjjqmmunnvtbopcplrbso; /usr/bin/python /home/prod/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310/service;
rm -rf /home/prod/.ansible/tmp/ansible-tmp-1410327554.04-167734794521310/ >/dev/null 2>&1’”‘"’’

`

Any Suggestion?

So your ansible version is VERY old, which could be causing your problem. Most likely it’s a lack of a sudo password unless this is not the first task in your playbook, but it’s hard to say.

Since then, there have been two new major releases, including security updates along the way.

Can you please try this with Ansible 1.7.1, and then if you are still having problems, please confirm where your Elastic Search package came from, your OS platform that is running it?

Thanks for Quick Response. Sure I will make try with ansible 1.7.1.

We have added elasticsearch latest version in our repo and installing through yum. (yum install elasticsearch)

and I am trying this on CentOS 6.3.

I tried playbook on ansible 1.8 but problem still same.

Fix this problem. Cause of the issue. I am using old version of service wrapper script for elasticsearch. After update /etc/init.d/elasticsearch everything is working fine.