[Python] ansible ansible_python_interpreter_fallback not working

Discussão em 'Python' iniciado por Stack, Novembro 29, 2024.

  1. Stack

    Stack Membro Participativo

    I have a playbook with a mix of connection: local tasks and remote tasks that use an AWS dynamic inventory. The python interpreter has different paths on local and remote systems.

    Through another question python3 venv - how to sync ansible_python_interpreter for playbooks that mix connection:local and target system I have determined I should use ansible_python_interpreter_fallback to configure 2 python interpreter paths to try. But I cannot get them working. I have tried:

    Playbook:

    ---

    - hosts: tag_group_web_servers
    vars_files:
    - group_vars/au
    roles:
    - autodeploy
    vars:
    ansible_python_interpreter_fallback:
    - /Users/jd/projects/mgr2/ansible/bin/python3
    - /usr/bin/python3


    (ignored)

    Dynamic inventory:

    plugin: aws_ec2
    regions:
    - ap-southeast-2
    - us-east-1
    hostnames:
    - ip-address
    keyed_groups:
    - prefix: "tag"
    key: tags
    - prefix: "group"
    key: tags
    - prefix: "security_groups"
    key: 'security_groups|json_query("[].group_name")'
    all:
    hosts:
    127.0.0.1:
    ansible_connection: local
    ansible_python_interpreter: "/Users/jd/projects/mgr2/ansible/bin/python3"
    remote:
    ansible_host: remote.host.ip
    ansible_python_interpreter: /usr/bin/python3
    ansible_python_interpreter_fallback:
    - /Users/jd/projects/mgr2/ansible/bin/python3
    - /usr/bin/python3


    (ignored)

    I'm confused where else this can go or why it doesn't work. Ansible version is here:

    ansible [core 2.17.4]
    config file = /Users/jd/projects/mgr2/ansible/ansible.cfg
    configured module search path = ['/Users/jd/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
    ansible collection location = /Users/jd/.ansible/collections:/usr/share/ansible/collections
    executable location = /opt/homebrew/bin/ansible
    python version = 3.11.10 (main, Sep 7 2024, 01:03:31) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/opt/python@3.11/bin/python3.11)
    jinja version = 3.1.4
    libyaml = True

    Continue reading...

Compartilhe esta Página