I'm not looking for a solution to fix the below python interpreter discovery failed error:
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
Instead, what i need is to log IPs where python discovery failed.
Below is my plabook where i'm able to log failed, telnet and failed ssh from my ansible host. However, I wish to also log failed python discovery.
Below is my playbook.
- 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
For successful ssh connectivity how can i detect if python_interpreter was discovered by ansible on the target host ?
Thus, I'm looking for the below:
- raw: "Python could not be discovered on IP {{ item }}"
delegate_to: localhost
when: <>
How to suppress the fatal error of discover_python_interpreter and log all the IPs using raw
module where it is missing.