Given fact_caching=jsonfile and ansible_python_interpreter: auto,
when we delegate_to a host as the first task in a play, the python interpreter of the host we delegate to
is what gets cached as the discovered_interpreter_python of the host the play is defined for.
- name: first playbook
hosts: bastion01.stg.phx2.fedoraproject.org
user: root
gather_facts: False
tasks:
- name: get vm list
delegate_to: "virthost05.stg.phx2.fedoraproject.org"
virt: command=list_vms
register: result
check_mode: no(context: bastion01.stg.phx2.fedoraproject.org is a RHEL 8 host with no /usr/bin/python. virthost05.stg.phx2.fedoraproject.org is a RHEL 7 host with /usr/bin/python installed/available.)
[codeblock@batcave01 test][PROD]$ sudo cat /root/.ansible_facts_cache/bastion01.stg.phx2.fedoraproject.org
{
"discovered_interpreter_python": "/usr/bin/python"
}
Either
"discovered_interpreter_python": "/usr/bin/python3"
or
"discovered_interpreter_python": "/usr/libexec/platform-python"