ansible_mitogen: rediscover python on local connection
Fixes the python discovery on delegate_to: localhost
Reading some opened issues it seems like there's an issue when delegating to other hosts as well. But I cannot check this behavior personally.
This is the first attempt to fix it, and I think it's not very effective to rediscover python on every local connection. I think it's possible to make it rediscover conditionally, i.e. when switching from one host to another.
This has been tested against v0.3.3. The version on master doesn't work for me.
Related:
- https://github.com/mitogen-hq/mitogen/issues/955
I get this issue when delegating in general e.g.:
hosts: suse-host
tasks:
- name: delegated with wrong python interpreter
command: echo success
delegate_to: debian-host
Will end up with /usr/bin/python3.6: No such file or directory and indeed debian doesn't really carry python 3.6 anymore, but ansible decided to pass the discovered interpreted onto it instead of discovering the correct one.
This looks the same as https://github.com/ansible/ansible/issues/61002, maybe mitogen overrides a key part of the fix?