-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Python interpreter discovery #50163
Python interpreter discovery #50163
Conversation
Suggestion: Since all of the bugs I found in the script that's shipped over to the remote host involve what happens to os-release, it might be better to simply read and return os-release to the controller. We can then use libraries on the controller to parse it and decide what to do. If we always return os-release and the results of platform.dist if available, that could also give us the opportunity to override platform.dist if we need to. |
# FIXME: use one invocation of `command -v` with multiple values and a multiline regex instead? | ||
exec_tmpl = "echo FOUND `command -v '{0}'` ENDFOUND" | ||
|
||
python_locator = self._connection._shell._SHELL_AND.join(["uname", ";".join([exec_tmpl.format(t) for t in bootstrap_python_list])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done in the shell plugin
This comment has been minimized.
This comment has been minimized.
lib/ansible/config/base.yml
Outdated
rhel: *rhelish | ||
ubuntu: | ||
'14': /usr/bin/python | ||
'16': /usr/bin/python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way for users to specify dicts in their config files? Or is this a config setting that they won't be able to override because they can't match the data format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no ini
or env
here, so it wouldn't be modifiable via config. Also, until we support YAML configs, it wouldn't be settable by a user even if it was exposed.
return self.message | ||
|
||
def __repr__(self): | ||
return self.message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repr should say how to recreate the class whenever possible:
>>> repr(err)
"ZeroDivisionError('integer division or modulo by zero',)"
>>> print(err)
integer division or modulo by zero
return self.message | |
return 'InterpreterDiscoveryRequiredError({0}, {1}, {2})'.format(self.message, self.interpreter_name, self.discover_mode) |
66c5d11
to
283c627
Compare
0031f46
to
86f912e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made suggested changes in a branch - see https://github.com/acozine/ansible/commits/PR50163.
276552f
to
917e610
Compare
* No longer blindly default to only `/usr/bin/python` * `ansible_python_interpreter` defaults to `auto_legacy`, which will discover the platform Python interpreter on some platforms (but still favor `/usr/bin/python` if present for backward compatibility). Use `auto` to always use the discovered interpreter, append `_silent` to either value to suppress warnings. * includes new doc utility method `get_versioned_doclink` to generate a major.minor versioned doclink against docs.ansible.com (or some other config-overridden URL)
(cherry picked from commit 5b53c0012ab7212304c28fdd24cb33fd8ff755c2)
917e610
to
6ad24d9
Compare
rebuild_merge |
6ad24d9
to
9ee7f2d
Compare
rebuild_merge |
Unstable tests appear to be Fedora-infra, unrelated... Merging by request. |
SUMMARY
/usr/bin/python
ansible_python_interpreter
defaults toauto_legacy
, which will discover the platform Python interpreter on some platforms (but still favor/usr/bin/python
if present for backward compatibility). Useauto
to always use the discovered interpreter.ISSUE TYPE
COMPONENT NAME
BaseAction
ADDITIONAL INFORMATION