Skip to content

Instantly share code, notes, and snippets.

@relrod
Last active November 14, 2019 23:43
Show Gist options
  • Save relrod/d957dd47c7d6d55ab351034076fc4e8d to your computer and use it in GitHub Desktop.
Save relrod/d957dd47c7d6d55ab351034076fc4e8d to your computer and use it in GitHub Desktop.

Ansible issue

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.

Reproducer playbook

- 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.)

Actual output

[codeblock@batcave01 test][PROD]$ sudo cat /root/.ansible_facts_cache/bastion01.stg.phx2.fedoraproject.org
{
    "discovered_interpreter_python": "/usr/bin/python"
}

Expected output

Either

"discovered_interpreter_python": "/usr/bin/python3"

or

"discovered_interpreter_python": "/usr/libexec/platform-python"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment