Open ifalatiksetlog opened 3 months ago
Using Python 3.12 on the controller (macOS 14.6, venv) and a Debian 11 target (Proxmox LXC guest) I couldn't reproduce this.
➜ tmp python3.12 -mvenv v312
➜ tmp v312/bin/pip install ansible==10.3.0 mitogen
...
Successfully installed MarkupSafe-2.1.5 PyYAML-6.0.2 ansible-10.3.0 ansible-core-2.17.3 cffi-1.17.0 cryptography-43.0.0 jinja2-3.1.4 mitogen-0.3.9 packaging-24.1 pycparser-2.22 resolvelib-1.0.1
➜ tmp ANSIBLE_STRATEGY=mitogen_linear ANSIBLE_STRATEGY_PLUGINS=v312/lib/python3.12/site-packages/ansible_mitogen/plugins/strategy v312/bin/ansible -mping d11.mynet
[WARNING]: Platform linux on host d11.mynet is using the discovered Python interpreter at /usr/bin/python3.9, but future installation of another Python interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-core/2.17/reference_appendices/interpreter_discovery.html for more information.
d11.mynet | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3.9"
},
"changed": false,
"ping": "pong"
}
➜ tmp v312/bin/python --version; v312/bin/pip list
Python 3.12.5
Package Version
------------ -------
ansible 10.3.0
ansible-core 2.17.3
cffi 1.17.0
cryptography 43.0.0
Jinja2 3.1.4
MarkupSafe 2.1.5
mitogen 0.3.9
packaging 24.1
pip 24.2
pycparser 2.22
PyYAML 6.0.2
resolvelib 1.0.1
➜ tmp ssh d11.mynet "ls /usr/bin/python*"
/usr/bin/python3
/usr/bin/python3.9
➜ tmp ssh d11.mynet /usr/bin/python3 --version; ssh d11.mynet /usr/bin/python3.9 --version
Python 3.9.2
Python 3.9.2
Could you provide a minimal reproduction without ARA (e.g. single task playbook or /usr/bin/ansible invocation)? I don't think ARA would make a difference, but it's hard for me to rule out completely.
I believe the issue is with the target hosts still having python2 installed:
ssh $hostname "ls -lsh /usr/bin/python*"
0 lrwxrwxrwx 1 root root 7 Mar 2 2021 /usr/bin/python -> python2
0 lrwxrwxrwx 1 root root 9 Jul 28 2021 /usr/bin/python2 -> python2.7
3.4M -rwxr-xr-x 1 root root 3.4M Sep 19 2023 /usr/bin/python2.7
0 lrwxrwxrwx 1 root root 9 Apr 5 2021 /usr/bin/python3 -> python3.9
5.3M -rwxr-xr-x 1 root root 5.3M Feb 28 2021 /usr/bin/python3.9
Minimal reproduction using Vagrant: Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.hostname = "debian.local"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
vb.cpus = "4"
end
config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.network :forwarded_port, guest: 22, host: 2522, auto_correct: false, id: "ssh"
auto_config = false
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get upgrade -y
apt-get install -y python2
ln -s python2 /usr/bin/python
SHELL
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
ansible.compatibility_mode = "2.0"
end
end
ansible.cfg:
[defaults]
inventory = ./hosts.yml
strategy = mitogen_linear
strategy_plugins = /home/ifalatik/projects/python-venvs/ansible/lib/python3.12/site-packages/ansible_mitogen/plugins/strategy
playboook.yml:
---
- hosts: all
tasks:
- name: Ping
ping:
results in:
PLAY [all] *********************************************************************
TASK [Gathering Facts] *********************************************************
ERROR! [mux 67580] 15:33:46.413472 E mitogen.[ssh.172.22.160.1:2522]: while importing u'ansible.module_utils.json_utils'
Traceback (most recent call last):
File "<stdin>", line 1710, in load_module
SyntaxError: future feature annotations is not defined (json_utils.py, line 27)
ok: [default]
[WARNING]: Platform linux on host default is using the discovered Python
interpreter at /usr/bin/python3.9, but future installation of another Python
interpreter could change the meaning of that path. See
https://docs.ansible.com/ansible-
core/2.17/reference_appendices/interpreter_discovery.html for more information.
TASK [Ping] ********************************************************************
ok: [default]
PLAY RECAP *********************************************************************
default : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Hi there, is there any work being done on this? Do you need more information?
I also believe this to be an issue with interpreter discovery with mitogen using python2 on systems where python
points to it, explicitly setting ansible_python_interpreter=/usr/bin/python3
resolves this issue. I think https://github.com/mitogen-hq/mitogen/issues/1097 cannot work when using mitogen as a strategy plugin before Ansible has had chance to perform interpreter discovery on the remote machine.
It also seems that mitogen fails to consider the global ansible python interpreter configuration? While setting ansible_python_interpreter=/usr/bin/python3
works, having the following in ansible.cfg
does not:
[defaults]
interpreter_python = /usr/bin/python3
Feel free to tell me if that would need a separate issue
still broken in 3.11
I am seeing the above-mentioned warning with the following:
Setting interpreter_python
and/or ansible_python_interpreter
has no effect.
pyproject.toml
[tool.poetry.dependencies]
python = "^3.11"
ansible-core = "^2.17.5"
ansible-lint = { version = "^24.9.2", markers = "platform_system != 'Windows'" }
passlib = "^1.7.4"
jmespath = "^1.0.1"
After upgrading to ansible v10.3.0 and mitogen 0.3.9 I now receive the following error before the first role of my playbook is executed:
I also receive this warning, before the first task is executed:
These didn't occur previously, don't occur without mitogen strategies and don't occur when setting
ansible_python_interpreter=/usr/bin/python3.9
explicitely.Host information
Target information
Verbose ansible:
(
... -vvv 2>&1 | grep 'future feature annotations' -C50
)Ansible config: