Hi all,
I came across service_facts (seems like previously called scan_services) to gather information about available services on the host, and their state.
Soon I realized that some services were missing, solution was to add service in chkconfig (for sysv or enable them in systemd). However, still some services tend to be missed, and some have state: stopped when they are running (turns out the service needs to be chkconfig on, not just --add, but that partialy solves the issue).
Is anyone familiar with this module and how the services on host are supposed to be configured in order to get the full list of services (both running and stopped)?
Part of the issue is resolved with -become=true (:facepalm: …I know), forgot to escalate privileges which is needed to get the correct state of the service…
But still I’m not able to get to services that are not chkconfiged (or systemctl enabled)…
Is there any workaround to get the state of those services with this module?
OK, I seem to have found the root cause of the issue… in case someone needs this.
The module tries to determine which is the best way to gather the list of services (comands: service --status-all or initctl list or chkconfig --list). It seems like the service --status-all fails, since this command tends to output some additional infos for some services. iptables etc.
I’m not python expert, but this block is just my guessing I might be wrong:
`
for line in stdout.split(“\n”):
line_data = line.split()
if len(line_data) < 4:
continue # Skipping because we expected more data
`
and so, it ends up gathering the list from chkconfig --list output.
Seems like there is no ideal way of handling this situation, and authors already came up with all the possible solutions
Now, the only thing I can think of right now, is to simply go through the list of all init scripts in /etc/init.d and do a service [service.name] status, and then inspect the exit code and deciding upon that what is the state of the service… ==0 or !==0
I guess I’ll have to learn more about python in the next few days in order to write something like this.
Hope this will help if someone comes across the same issue…