我不是在寻找解决以下 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。