当我使用 "service" 模块时,如何判断 Ansible 运行的是哪个初始化系统?
How can I tell which init system Ansible runs when I use the "service" module?
来自the Ansible documentation,服务模块:
Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.
对于给定的机器,我如何知道 Ansible 使用的是哪个初始化系统?例如,一个系统可能有 init 和 systemd。
主机上的初始化系统作为 Ansible 事实可用 ansible_service_mgr
。
让我们看看模块' code:
里面 def main():
:
# Find service management tools
service.get_service_tools()
然后 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
...
我已经删减了一些代码,但这段代码应该可以回答您的问题:如果有很多系统,Ansible 可能会选择什么系统。
Systemd 是第一个搜索的,然后是 upstart,等等...
来自the Ansible documentation,服务模块:
Controls services on remote hosts. Supported init systems include BSD init, OpenRC, SysV, Solaris SMF, systemd, upstart.
对于给定的机器,我如何知道 Ansible 使用的是哪个初始化系统?例如,一个系统可能有 init 和 systemd。
主机上的初始化系统作为 Ansible 事实可用 ansible_service_mgr
。
让我们看看模块' code:
里面 def main():
:
# Find service management tools
service.get_service_tools()
然后 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
...
我已经删减了一些代码,但这段代码应该可以回答您的问题:如果有很多系统,Ansible 可能会选择什么系统。
Systemd 是第一个搜索的,然后是 upstart,等等...