[manual] [PR:19258] Fix shebang to /usr/bin/python in ansible modules for compatibility#944
Draft
cyw233 wants to merge 1 commit intoAzure:202405from
Draft
[manual] [PR:19258] Fix shebang to /usr/bin/python in ansible modules for compatibility#944cyw233 wants to merge 1 commit intoAzure:202405from
cyw233 wants to merge 1 commit intoAzure:202405from
Conversation
…#19258) What is the motivation for this PR? We encountered the following issue when trying to upgrade ansible: /bin/sh: 1: /usr/bin/env python3: not found This error occurred when attempting to invoke certain Ansible modules. According to the Module format and documentation, image the recommended shebang is: `#!/usr/bin/python` From the logs, we can observe the following behavior: When the shebang is /usr/bin/env python, Ansible translates it into: 203 1751357337.89274: _low_level_execute_command(): starting 203 1751357337.89277: _low_level_execute_command(): executing: /bin/sh -c ''"'"'/usr/bin/env python'"'"' && sleep 0' In contrast, when using /usr/bin/python, Ansible attempts a full interpreter discovery: 171 1751357179.48738: _low_level_execute_command(): starting 171 1751357179.48741: _low_level_execute_command(): executing: /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.13'"'"'; command -v '"'"'python3.12'"'"'; command -v '"'"'python3.11'"'"'; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python3'"'"'; echo ENDFOUND && sleep 0' This indicates that Ansible treats /usr/bin/env python literally and does not invoke its interpreter auto-discovery logic, leading to failures on systems without the python symlink. To satisfy the requirements of the latest ansible, we update the shebang lines in all affected modules in advance. How did you do it? To satisfy the requirements of the latest ansible, this PR updates the shebang lines in all affected modules to #!/usr/bin/python. How did you verify/test it? We need to make sure that this change won't affect current test firstly -- test by pipeline itself. And then, we need to make sure that this change works in the new version -- test locally.
Author
|
Original PR: sonic-net/sonic-mgmt#19258 |
Merged
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
We encountered the following issue when trying to upgrade ansible:
/bin/sh: 1: /usr/bin/env python3: not foundThis error occurred when attempting to invoke certain Ansible modules.
According to the Module format and documentation,
From the logs, we can observe the following behavior:
This indicates that Ansible treats
/usr/bin/env pythonliterally and does not invoke its interpreter auto-discovery logic, leading to failures on systems without the python symlink.To satisfy the requirements of the latest ansible, we update the shebang lines in all affected modules in advance.
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
We encountered the following issue when trying to upgrade ansible:
/bin/sh: 1: /usr/bin/env python3: not foundThis error occurred when attempting to invoke certain Ansible modules.
According to the Module format and documentation,
From the logs, we can observe the following behavior:
This indicates that Ansible treats
/usr/bin/env pythonliterally and does not invoke its interpreter auto-discovery logic, leading to failures on systems without the python symlink.To satisfy the requirements of the latest ansible, we update the shebang lines in all affected modules in advance.
How did you do it?
To satisfy the requirements of the latest ansible, this PR updates the shebang lines in all affected modules to #!/usr/bin/python.
How did you verify/test it?
We need to make sure that this change won't affect current test firstly -- test by pipeline itself. And then, we need to make sure that this change works in the new version -- test locally.
Any platform specific information?
Supported testbed topology if it's a new test case?
Documentation