# The service module and failures (msg: service name not recognized)

**URL:** <https://forum.ansible.com/t/the-service-module-and-failures-msg-service-name-not-recognized/12421>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 25, 2013, 1:40pm UTC](https://forum.ansible.com/t/the-service-module-and-failures-msg-service-name-not-recognized/12421 "2013-02-25T13:40:51Z")\
**Posts on this page:** 3\
**Page:** 1

<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 25, 2013, 1:40pm UTC](https://forum.ansible.com/t/the-service-module-and-failures-msg-service-name-not-recognized/12421/1 "2013-02-25T13:40:51Z")

</div>

I disagree pretty strongly actually, If you typo a service name it  
should raise that to your attention immediately.

Same as if you typo a package, or reference a user group name that  
does not exist.

You don't want that to keep going and let you think it did what you  
asked about your infrastructure.

There is documentation about how to affix an conditional to a task  
include that may help you keep that level of complexity to a minimum.

tasks:

&nbsp;&nbsp;&nbsp;- include: foo.yml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when\_string: ${ansible\_distribution} == 'CentOS'

ETC.

--Michael

---

<div class="post-metadata">

**Author:** ![aamaas](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@aamaas](https://forum.ansible.com/u/aamaas)\
**Post date:** [February 25, 2013, 3:09pm UTC](https://forum.ansible.com/t/the-service-module-and-failures-msg-service-name-not-recognized/12421/2 "2013-02-25T15:09:09Z")

</div>

It’s what I already did. Still bothers me thought that it festers complexity.  
I didn’t mean for the logic to encompass different modules, but for the service module specifically. Thanks for the input though.

- H

---

<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 25, 2013, 4:37pm UTC](https://forum.ansible.com/t/the-service-module-and-failures-msg-service-name-not-recognized/12421/3 "2013-02-25T16:37:00Z")

</div>

Understood, though your use case of configuring things /if/ they are  
there is a bit of a niche one.

Generally you want to state what /should/ be somewhere, because if you  
said all the things that should not be, it gets more difficult.

I had the same exact problem when trying to wedge a certain other  
config tool into a certain compliance effort in the past.

It's still a HECK of a lot easier with ansible conditionals. You  
might consider writing a custom fact module that returns what is  
present and what is not.
