首页 > 解决方案 > Ansible playbook 任务 - 命令找不到 pid,但服务已正确启动

问题描述

我已经配置了一个剧本来安装、配置和启动 osquery 工具。playbook 执行时出现错误。“osqueryd 没有运行。没有找到 pidfile。”

完全错误

TASK [osquery-client : check agent status again] ********************************************************************************************************************
fatal: [13.57.34.71]: FAILED! => {"changed": true, "cmd": ["/usr/bin/osqueryctl", "status"], "delta": "0:00:00.021902", "end": "2019-10-16 19:19:50.523876", "msg": "non-zero return code", "rc": 7, "start": "2019-10-16 19:19:50.501974", "stderr": "", "stderr_lines": [], "stdout": "osqueryd is not running. no pidfile found.", "stdout_lines": ["osqueryd is not running. no pidfile found."]}

我的 task/main.yml 定义为:

- name: check agent status again
  command: /usr/bin/osqueryctl status
  ignore_errors: yes

pid文件位于这里

--pidfile=/var/run/osqueryd.pidfile

ansible 在错误的地方寻找 pid 吗?

标签: ansible

解决方案


将此睡眠命令添加到任务中似乎有效

- name: check agent status again
  command: /usr/bin/osqueryctl status
  command: sleep 5
  ignore_errors: yes

推荐阅读