Reputation: 64834
From the Ansible documentation, the service module:
Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.
For a given machine, how can I tell which init system Ansible is using? A system may have init and systemd on it, for example.
Upvotes: 12
Views: 8352
Reputation: 68269
Let's look into the modules' code:
Inside def main():
:
# Find service management tools
service.get_service_tools()
Then to class LinuxService(Service):
and to def get_service_tools(self):
# Locate a tool to enable/disable a service
if check_systemd():
# service is managed by systemd
...
elif location.get('initctl', False) and os.path.exists("/etc/init/%s.conf" % self.name):
# service is managed by upstart
...
elif location.get('rc-service', False):
# service is managed by OpenRC
...
elif self.svc_initscript:
# service is managed by with SysV init scripts
...
I've cut some code, but this snippet should answer your question: what system Ansible is likely to choose if there are many.
Systemd is the first one to search, then upstart, etc...
Upvotes: 7
Reputation: 3193
The init system on a host is available as Ansible fact ansible_service_mgr
.
Upvotes: 23