python - 如何使用 Ansible 记录 ansible_python_interpreter 失败的 IP?
问题描述
我不是在寻找解决以下 python 解释器发现失败错误的解决方案:
TASK [Gathering Facts]
fatal: [123.123.123.123]: FAILED! => {"changed": false,
"module_stderr": "/bin/sh: 1: /usr/bin/python: not found\n",
"module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 127
相反,我需要的是记录 python 发现失败的 IP。
下面是我的手册,我可以在其中从我的 ansible 主机记录失败、telnet 和失败的 ssh。但是,我还希望记录失败的 python 发现。
下面是我的剧本。
- name: Play 3- check nodes
hosts: localhost
tasks:
- name: Check all port numbers are accessible from current host
include_tasks: /app/checkssh/innertelnet.yml
with_items: "{{ groups['all_hosts'] }}"
cat innertelnet.yml
---
- wait_for:
host: "{{ item }}"
port: 22
state: started
delay: 0
timeout: 2
ignore_errors: yes
register: netstatoutput
- raw: "echo telnet failed on IP {{ item }}"
delegate_to: localhost
when: netstatoutput.failed == 'True'
- name: Check ssh connectivity
ignore_errors: yes
raw: "ssh -o BatchMode=yes root@{{ item }} echo success"
register: sshcheck
- raw: "echo ssh failed on IP {{ item }}"
delegate_to: localhost
when: not netstatoutput.failed and sshcheck is unreachable
对于成功的 ssh 连接,我如何检测 python_interpreter 是否被目标主机上的 ansible 发现?
因此,我正在寻找以下内容:
- raw: "Python could not be discovered on IP {{ item }}"
delegate_to: localhost
when: <>
如何抑制 discover_python_interpreter 的致命错误并使用raw
缺少它的模块记录所有 IP。
解决方案
推荐阅读
- sql - 当数据集很大时,有什么技巧可以避免或降低一对多连接和非等连接的成本?
- spring - 如何更改默认的 Spring Boot oauth url(/login/oauth2/code 和 /oauth2/authorization)?
- php - PHP打印页面的特定部分
- r - 按下关闭按钮时,有没有办法擦除 bsModal() 窗口的内容?
- docker - 你如何 dockerize 一个 WebSocket 服务器?
- python - 如何根据登录的用户限制多对多字段中的选择?
- javascript - 带有数组的 Javascript 对象来搜索参数样式查询字符串
- c++ - 如何在 win32 GUI 应用程序中向用户显示快速更新的数据?
- amazon-web-services - ECS 中 docker 任务的 Prometheus 指标抓取
- javascript - oncanplay 与 oncanplaythrough