[英]How can I tell which init system Ansible runs when I use the “service” module?
From the Ansible documentation , the service module: 从Ansible文档中 ,服务模块:
Controls services on remote hosts. 控制远程主机上的服务。 Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart. 支持的init系统包括BSD init,OpenRC,SysV,Solaris SMF,systemd,upstart。
For a given machine, how can I tell which init system Ansible is using? 对于给定的机器,我如何判断Ansible正在使用哪个init系统? A system may have init and systemd on it, for example. 例如,系统可以在其上具有init和systemd。
主机上的init系统可用作Ansible事实ansible_service_mgr
。
Let's look into the modules' code : 让我们看一下模块的代码 :
Inside def main():
: 内部def main():
::
# Find service management tools
service.get_service_tools()
Then to class LinuxService(Service):
and to def get_service_tools(self):
然后class LinuxService(Service):
和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. 我已经删除了一些代码,但是这段代码应该回答你的问题:如果有很多代码,Ansible可能会选择什么系统。
Systemd is the first one to search, then upstart, etc... Systemd是第一个搜索,然后新贵等...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.