# service doesn't exist

**URL:** <https://forum.ansible.com/t/service-doesnt-exist/11777>\
**Category:** Ansible Project\
**Created:** [August 9, 2012, 3:10pm UTC](https://forum.ansible.com/t/service-doesnt-exist/11777 "2012-08-09T15:10:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 9, 2012, 3:10pm UTC](https://forum.ansible.com/t/service-doesnt-exist/11777/1 "2012-08-09T15:10:23Z")

</div>

Hi,

Target is CentOS 5.8

I'm getting this error:  
TASK: [no xfs] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [cl009.test.net] =\> {"changed": false, "failed": true,  
"module": "service", "msg": "failed determining the current service  
state =\> state stays unchanged"}  
failed: [cl010.test.net] =\> {"changed": false, "failed": true,  
"module": "service", "msg": "failed determining the current service  
state =\> state stays unchanged"}

&nbsp;&nbsp;- name: no xfs  
&nbsp;&nbsp;&nbsp;&nbsp;action: service name=xfs state=stopped enabled=no

[root@cd ~]# chkconfig --list | grep xfs  
[root@cd ~]#

So the service doesn't exist but thats going to happen in my environment.

sheepchase:tasks jmarcus$ ansible --version  
ansible 0.6

Is this me? Is it helpful post this to the list or should I open a bug?

James

---

<div class="post-metadata">

**Author:** ![Ingo\_Gottwald](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@Ingo\_Gottwald](https://forum.ansible.com/u/Ingo_Gottwald)\
**Post date:** [August 9, 2012, 6:20pm UTC](https://forum.ansible.com/t/service-doesnt-exist/11777/2 "2012-08-09T18:20:22Z")

</div>

I’m sorry, I don’t see your Problem.

You forced the service module to stop a service that doesn’t exist.  
The service module hast to determine the service state first, before it can proceed with any actions.  
Because of the service that is not existing, it can’t determine it’s current state.

I don’t see anything wrong with that.

What would you expect to happen in this situation?

Regards

Ingo

---

<div class="post-metadata">

**Author:** ![James8](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@James8](https://forum.ansible.com/u/James8)\
**Post date:** [August 9, 2012, 8:23pm UTC](https://forum.ansible.com/t/service-doesnt-exist/11777/3 "2012-08-09T20:23:52Z")

</div>

Hi,  
Well I'm trying to make sure services are disabled, if they don't  
exist, I would prefer that the playbook wouldn't fail. That way I  
don't have to tune a playbook for each datacenter vendors distribution  
of CentOS. Does that make sense?

Thanks,  
James

---

<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:** [August 9, 2012, 8:26pm UTC](https://forum.ansible.com/t/service-doesnt-exist/11777/4 "2012-08-09T20:26:01Z")

</div>

So in 0.7 at some point in the next few weeks you will be able to  
write a statement and use the result of that statement in an only\_if  
using a last\_result variable.

I think I've mentioned this before.

Until then, you will have to write a custom fact module, like  
"site\_facts", and call it ahead of the service line in your playbook  
in order to detect if the service exists or not.

Having this succeed blindly seems like a bad thing because there could  
be typos, but you also have "ignore\_errors: True" on a task if you are  
feeling confident it will really work if the service is there. I  
don't recommend that though.
