# How to troubleshoot service module? ( incorrectly reports successful start / RHEL 6 )

**URL:** <https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [February 15, 2013, 7:58pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363 "2013-02-15T19:58:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 15, 2013, 7:58pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/1 "2013-02-15T19:58:58Z")

</div>

We have a custom written init script that never gets started when I do this:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 15, 2013, 8:07pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/2 "2013-02-15T20:07:01Z")

</div>

A custom init script could have various issues. I suspect it might  
not be demonizing correctly, though newer versions of Ansible more or  
less force this issue.

Are you using the latest development Ansible?

Note -- There are some upgrades to the service module we were going to  
do a point release for 1.1 on.

If you are having problems with reliable output from the service  
status command, pattern= is a useful option.

---

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 15, 2013, 9:06pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/3 "2013-02-15T21:06:58Z")

</div>

> A custom init script could have various issues. I suspect it might  
> not be demonizing correctly, though newer versions of Ansible more or  
> less force this issue.
> 
> Are you using the latest development Ansible?

No, I'm using 1.0. I will upgrade when I have some cycles.

> If you are having problems with reliable output from the service  
> status command, pattern= is a useful option.

I will give that a try if other options fail.

My first clue: I modified the init script and it seems that 'state=started' first calls the init script with an argument of 'status', rather than 'start'. /var/log/messages shows that ansible-service did get called with 'state=started'

Any comments on that observation? I will try to poke further when I have time.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 15, 2013, 9:27pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/4 "2013-02-15T21:27:58Z")

</div>

Sounds like you don't support status yet.

If you don't support status you must call the service module with the  
pattern= argument.

It's explained a bit on the module doc section.

---

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 15, 2013, 10:05pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/5 "2013-02-15T22:05:31Z")

</div>

I checked the doc; it mentions "respond to the status command". What does that mean?

The init script in question \*DOES\* support status. It reports some running pid info, and then spits out some other diag info. Return code is 0.

---

<div class="post-metadata">

**Author:** ![VK1](https://avatars.discourse-cdn.com/v4/letter/v/bbce88/32.png) [@VK1](https://forum.ansible.com/u/VK1)\
**Post date:** [February 15, 2013, 10:20pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/6 "2013-02-15T22:20:10Z")

</div>

OK. From some tests, I think 'respond to the status command' really means returns with non-zero if service is not running. Is this correct?

It would be worth clarifying in the docs.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 15, 2013, 10:44pm UTC](https://forum.ansible.com/t/how-to-troubleshoot-service-module-incorrectly-reports-successful-start-rhel-6/12363/7 "2013-02-15T22:44:51Z")

</div>

Hmmm....

I personally don't think we need to document how to write a service  
init script in our docs, per se, as that is pretty well standard to  
the way that you have to write service init scripts so they work with  
the 'service' command in the OS.
