Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible: Respect interpreter_python config #833

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

extmind
Copy link

@extmind extmind commented Apr 29, 2021

Use the global configuration variable interpreter_python when ansible_python_interpreter is unset.

Fixes #740

Edit: @moreati clarify config vs variable distinction

@extmind extmind force-pushed the interpreter_python branch from bab22aa to afe0026 Compare May 5, 2021 18:11
@philfry philfry mentioned this pull request Mar 8, 2024
@stefanor
Copy link
Contributor

@moreati: Thanks for the more frequent releases.

This is one of the patches that Debian has been carrying for a while. As we don't have a /usr/bin/python in the distro any more, it's common to have interpreter_python configured. I'd appreciate it if you would re-review this PR.

@moreati moreati self-assigned this Apr 12, 2024
@moreati moreati changed the title ansible: Respect interpreter_python config variable ansible: Respect interpreter_python config Dec 19, 2024
@moreati
Copy link
Member

moreati commented Dec 19, 2024

Sorry for the long wait. I've been avoiding the interpreter discovery code for far too long. I've now tackled most of templating connection options/variables and connection timeout, and I have a mcuh better understanding of the ... intricacies.

This patch looks broadly correct. I'm going to update for master, rejig a couple of details, and add some tests.

@moreati moreati mentioned this pull request Dec 19, 2024
@moreati
Copy link
Member

moreati commented Dec 19, 2024

The failure in https://github.com/mitogen-hq/mitogen/actions/runs/12412205309/job/34651500318?pr=833

TASK [assert_equal left=out.result[0].kwargs.python_path, right=['{{out.discovered_interpreter}}']] ***
Thursday 19 December 2024  12:07:55 +0000 (0:00:00.056)       0:07:56.582 ***** 
fatal: [tc-python-path-hostvar]: FAILED! => changed=false 
  msg: |-
    Lists differ: ['/hostvar/path/to/python'] != [False]
  
    First differing element 0:
    '/hostvar/path/to/python'
    False
  
    - ['/hostvar/path/to/python']
    + [False]

is perplexng. The test is expecting ansible_mitogen.plugins.action.mitogen_get_stack.ActionModule()._connection._action._discovered_interpreter == u'/hostvar/path/to/python'. However that value could only come from

[tc_python_path]
tc-python-path-unset
tc-python-path-hostvar ansible_python_interpreter=/hostvar/path/to/python
which by definition makes it not a discovered python interpreter.

I need to confirm the semantics of ansible.plugins.ActionBase._discovered_python in vanilla Ansible.

@moreati
Copy link
Member

moreati commented Dec 19, 2024

Going by ansible/ansible@4d3a612#diff-cbe4262a246b2475f3884118713f2ae5a6c49a443d9a942b6c63445bed9354dcR32

  • ansible.plugins.action.ActionBase._discovered_interpreter starts False.
  • It's assigned the path of an interpreter on the targert if and only if interpreter discvoery is run.
  • Assignment to ActionBase._discovered_interpreter is closely tied to populating the variable discovered_interpreter_python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ansible+Mitogen ignores interpreter_python global config
3 participants