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

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:

   - include: foo.yml
     when_string: ${ansible_distribution} == 'CentOS'

ETC.

--Michael

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

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.