Hi all,
I have an Ansible target machine running Rocky Linux 8 with Python 3.9.19 installed.
[ansible@punch2 ~]$ python3 --version
Python 3.9.19
[ansible@punch2 ~]$ which python3
/usr/bin/python3
[ansible@punch2 ~]$ file $(which python3)
/usr/bin/python3: symbolic link to /etc/alternatives/python3
[ansible@punch2 ~]$ file /etc/alternatives/python3
/etc/alternatives/python3: symbolic link to /usr/bin/python3.9
On my control node I have ansible-core 2.17.1
and python 3.12.4
According to the ansible-core
support matrix [1] this should be a working combination.
However, running my playbook fails with
TASK [install rsync] *********************************************************************************************************************
fatal: [punch2]: FAILED! => {"changed": false, "module_stderr": "Shared connection to punch2 closed.\r\n", "module_stdout": "\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 12, in <module>\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_ansible.legacy.dnf_payload_7b004s9t/ansible_ansible.legacy.dnf_payload.zip/ansible/module_utils/basic.py\", line 5\r\nSyntaxError: future feature annotations is not defined\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
The affected task is:
- name: "install rsync"
ansible.builtin.dnf:
name: "rsync"
state: "present"
I thought perhaps ansible uses an incorrect python executable on the target host, but it looks like it uses the correct one:
$ grep -i python /tmp/ansible.log
"SUDO_COMMAND": "/bin/sh -c echo BECOME-SUCCESS-zjjlkkwbuieqcjgtuknfnroqnampysct ; /usr/bin/python3.9 /home/ansible/.ansible/tmp/ansible-tmp-1718955443.6279042-120117-145070664808475/AnsiballZ_setup.py",
"_": "/usr/bin/python3.9"
"discovered_interpreter_python": "/usr/bin/python3.9",
"SUDO_COMMAND": "/bin/sh -c echo BECOME-SUCCESS-zjjlkkwbuieqcjgtuknfnroqnampysct ; /usr/bin/python3.9 /home/ansible/.ansible/tmp/ansible-tmp-1718955443.6279042-120117-145070664808475/AnsiballZ_setup.py",
"_": "/usr/bin/python3.9"
"python": {
"executable": "/usr/bin/python3.9",
"type": "cpython",
"python_version": "3.9.19",
"selinux_python_present": true,
"ansible_playbook_python": "/usr/bin/python",
"ansible_python": {
"executable": "/usr/bin/python3.9",
"type": "cpython",
"ansible_python_version": "3.9.19",
"ansible_selinux_python_present": true,
"discovered_interpreter_python": "/usr/bin/python3.9",
Is this the expected behaviour?
When I downgrade ansible-core
on my control node to 2.16.6
, the playbook runs normally.
[1] Releases and maintenance â Ansible Community Documentation