Ansible ping module fails "read header failed: Broken pipe" "Received exit status from master 1"

Ansible ping module fails “read header failed: Broken pipe” “Received exit status from master 1”.

Practicing ansible, and trying to using ping module from a Jenkins container and its FAILED

test1 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "module_stderr": "OpenSSH_9.2p1 Debian-2+deb12u3, OpenSSL 3.0.15 3 Sep 2024\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/var/jenkins_home/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/var/jenkins_home/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 619\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to remote-host closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/cisco/.ansible/tmp/ansible-tmp-1735347690.1000645-615-56325765900466/AnsiballZ_ping.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/cisco/.ansible/tmp/ansible-tmp-1735347690.1000645-615-56325765900466/AnsiballZ_ping.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/cisco/.ansible/tmp/ansible-tmp-1735347690.1000645-615-56325765900466/AnsiballZ_ping.py\", line 44, in invoke_module\r\n    from ansible.module_utils import basic\r\n  File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\r\n  File \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\r\n  File \"<frozen importlib._bootstrap>\", line 894, in _find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1157, in find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1131, in _get_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1112, in _legacy_get_spec\r\n  File \"<frozen importlib._bootstrap>\", line 441, in spec_from_loader\r\n  File \"<frozen importlib._bootstrap_external>\", line 544, in spec_from_file_location\r\n  File \"/tmp/ansible_ping_payload_0sgld7vl/ansible_ping_payload.zip/ansible/module_utils/basic.py\", line 5\r\nSyntaxError: future feature annotations is not defined\r\n",
    "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error",
    "rc": 1
}
  • Include the version(s) of the relevant software tools, libraries, collections etc:
ansible [core 2.18.1]
  config file = None
  configured module search path = ['/var/jenkins_home/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/dist-packages/ansible
  ansible collection location = /var/jenkins_home/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0] (/usr/bin/python3)
  jinja version = 3.1.5
  libyaml = True
jenkins@724ff3286da3:~/ansible$ python3 --version
Python 3.11.2

Ansible is using the Python interpreter /usr/bin/python3 on the remote, which apparently does not satisfy the version requirements. SyntaxError: future feature annotations is not defined indicates that /usr/bin/python3 is older than Python 3.8, the minimum requirement for ansible-core 2.18 (https://docs.ansible.com/ansible-core/devel/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix). From the error message I’d guess it’s Python 3.6.

You have to point Ansible at a newer Python version on the remote to be able to use it.

How sensible is it to design deployment-configuration software that creates dependencies on software and systems that cannot be upgraded on the systems it is purporting to deploy/configure?

Using newer tech is fine, but fallback mechanisms should always be available for legacy systems. ALWAYS

Isn’t the fallback mechanism to use an older version of Ansible to manage the older systems? Also, it makes sense for the newer versions of Ansible to support contemporary versions of Python. The developers would inevitably need to drop supporting old ones to keep from drowning trying to balance out-of-support versions of Python and implementing new features.