Is there a way to check if a service is already enabled on a linux machine?

I don’t see a way to do it with service_facts, do I have to use shell magic?

You can use the appropriate service module:

- service: name=myservice enabled=yes
  check_mode: true
  register: isit

- fail: msg=its not enabled
  when: isit is changed

Awesome! Thanks!

YK

Awesome! Thanks!

As an option, you can also use the service_facts module to inspect
service state: https://docs.ansible.com/ansible/latest/modules/service_facts_module.html#service-facts-module

-AdamM

>
> Awesome! Thanks!

As an option, you can also use the service_facts module to inspect
service state: https://docs.ansible.com/ansible/latest/modules/service_facts_module.html#service-facts-module

You can not, because the facts do not tell whether a service is enabled
or disabled.

P.

I was actually thinking of trying to change that, but I’m short on time. Should I log a ticket or is that out of scope for the module?

I was also thinking about making it possible for service_facts to operate only on a single service, in order to save time on data collection. Same question - should I log something for that or is it out of scope?

I was actually thinking of trying to change that, but I'm short on time. Should I log a ticket or is that out of scope for the module?

I was also thinking about making it possible for service_facts to operate only on a single service, in order to save time on data collection. Same question - should I log something for that or is it out of scope?

Please file an issue ticket, that's something the module should
probably be providing. I actually thought it did (which I'm apparently
mistaken on).

-AdamM

done, for both:
https://github.com/ansible/ansible/issues/43641

https://github.com/ansible/ansible/issues/43642