Start service if is not running

Guys,

I would like to start a service if is not running on my target.

What is the best practice to do that?

Example:

when: my_agent == False ?
when_false

Thanks

Use the service module with "state: started".

Thanks fro your feedback.
Yes I know… but I would like something like that:

If my service is running I don’t want to reinstall all package.
I would like to manage that with a “register” output from my service state.

-name= check if service is running
service: name=ctmagent.service state=started
register=ctmagent

-name = Clean Install
file: example
when: ctmagent >> ( Idon’t know how to manage the when)

Thanks

Hi

I don't understand... making sure a service is running is distinctly
different from making sure it's installed.
The only dependency I can see is that it has to be installed before
you can ensure it's running (or not).

Dick