【发布时间】:2021-10-30 02:07:08
【问题描述】:
我使用service_facts 来检查服务是否正在运行和启用。在某些未安装特定软件包的服务器中。
现在,使用service_facts module,我怎么知道这个特定的包没有安装在那个特定的服务器上?
在 Ansible 剧本中显示以下错误:
localhost | SUCCESS => {
"ansible_facts": {
"services": {
"acpid.service": {
"name": "acpid.service",
"source": "systemd",
"state": "running",
"status": "enabled"
},
"agent_installation.service": {
"name": "agent_installation.service",
"source": "systemd",
"state": "stopped",
"status": "unknown"
}, "changed": false,
"msg": "WARNING: Could not find status for all services. Sometimes this is due to insufficient privileges."
}
【问题讨论】:
-
我在您的示例输出中看不到任何错误。你到底期待什么?
-
这是我从该特定服务器收到的消息:
"msg": "WARNING: Could not find status for all services. Sometimes this is due to insufficient privileges." -
是的,这是一个警告,而不是错误。那么你到底期望什么?你想检查什么?如果您需要仅对 root 可用的服务状态,则需要提升权限。
-
我需要使用 ansible_facts 获取 falcon 和 nessus 的服务状态。这条消息来了,其中 falcon 和 nessus 没有安装在该服务器上。如何在剧本中处理这个问题。
-
这意味着您拼错了服务名称(您可能应该使用
falcon-sensor而不是falcon-sensor.service)或者该服务不是由 systemd 管理的,并且可能由还有什么?