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

Remove Python shebang #49

Open
1 task done
sean-freeman opened this issue Nov 9, 2024 · 4 comments
Open
1 task done

Remove Python shebang #49

sean-freeman opened this issue Nov 9, 2024 · 4 comments

Comments

@sean-freeman
Copy link
Member

sean-freeman commented Nov 9, 2024

Summary

Remove Python shebang from all Ansible Modules, which cause errors with Python venv edit: when using Ansible Core 2.17+:
https://github.com/search?q=repo%3Asap-linuxlab%2Fcommunity.sap_libs%20%23!&type=code

See Ansible Core built-in modules for proof (shebang only exists on hostname Ansible Module):
https://github.com/search?q=repo%3Aansible%2Fansible+path%3A%2F%5Elib%5C%2Fansible%5C%2Fmodules%5C%2F%2F+%23%21&type=code

Issue Type

Bug Report

Component Name

python

Ansible Version

N/A

community.sap_libs Version

All

Configuration

N/A

OS / Environment

No response

Steps to Reproduce

N/A

Expected Results

N/A

Actual Results

No response

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@kksat
Copy link

kksat commented Nov 9, 2024

I would like to leave it here for your information only:

https://docs.ansible.com/ansible/latest/dev_guide/testing/sanity/shebang.html

"
This does not apply to Ansible modules, which should not be executable and must always use #!/usr/bin/python.

Some exceptions are permitted. Ask if you have questions.
"

@kksat
Copy link

kksat commented Nov 9, 2024

I read links you provided in full. Your take from the links you posted is that python shebang should be completely removed from ansible modules (as in the title of this bug)?

My understanding is different and more close to the statement from sanity documentation that ansible python modules should always use '#!/usr/bin/python' as shebang. I would appreciate if you can elaborate on your understanding and implications you see for an ansible collection from the links you posted.

@sean-freeman
Copy link
Member Author

@kksat Already tested #!/usr/bin/python and it still doesn't work with auto on https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python + using Python with venv.

Hence provided the Ansible built-in modules as proof of the removal.

Removing shebang has no functional impact on the Ansible Module, but does solve problems where the target (or localhost etc) that is executing the Ansible Module (Python file) is required to use a specific interpreter / venv.

Otherwise it will always attempt to use the System Python, which may be locked to a much older version and the end-user (best practice) does not wish to install additional Python Packages to the System Python; for stability and security reasons.

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

No branches or pull requests

2 participants