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

Use console_scripts and module entry points #39253

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
6 participants
@ssbarnea
Contributor

ssbarnea commented Apr 24, 2018

SUMMARY

Allow calling ansible using python -m ansible instead of using cli script.
Enables use of ansible in situations where CLI scripts are not available or when they are not in PATH.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

core

ANSIBLE VERSION
2.6.0.0
ADDITIONAL INFORMATION

Migrate to console_scripts and module entry point
Allow calling ansible using `python -m ansible` instead of using cli script.
Enables use of ansible in situations where CLI scripts are not available or when they are not in PATH.

Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
@sivel

This comment has been minimized.

Member

sivel commented Apr 24, 2018

This would still only allow execution of the adhoc CLI correct? It would not allow for executing a playbook via python -m.

Additionally this would make us more dependent on setuptools, which I don't think we want.

Based on previous discussions, I believe the bin scripts would still need to exist, and import and call the code from __main__, instead of relying on setuptools to create the scripts.

As it is, this also breaks running ansible from source due to the reliance on setuptools.

@bcoca bcoca removed the needs_triage label Apr 24, 2018

@abadger

This comment has been minimized.

Member

abadger commented Apr 24, 2018

yeah, -1 to this implementation. We should continue to have scripts but they should be light wrappers. of things in cli. (The goal should be to minimize use of setuptools, especially at runtime.)

I think that to start with, we should only enable python -m ansible.cli.SOMETHING to work. That way people can access any of the command line scripts via python -m. At some point in the future we can implement ansible/main.py to map to either ad hoc or playbook... but right now it isn't apparent to me which one of those we should choose.

@ansibot ansibot added the bug label Apr 24, 2018

@ssbarnea

This comment has been minimized.

Contributor

ssbarnea commented Apr 25, 2018

Ok, if we want to be able to run ansible from source without installing the package, keeping minimal wrapper scripts should be needed. I personally do not see the point for keeping them, especially as the installer would be able to create more flexible scripts.

Still, I will follow your instructions and update the PR to keep the files and only to enable the entry points (without duplicating implementation).

@mattclay

This comment has been minimized.

Member

mattclay commented Apr 26, 2018

CI failure in sanity tests: https://app.shippable.com/github/ansible/ansible/runs/62511/1/tests

CI failure in integration tests due to ansible* executables not being in the path:

2018-04-24 20:31:56 Traceback (most recent call last):
2018-04-24 20:31:56   File "/tmp/ansible-test-coverage-6PITfS/coverage/ansible-playbook", line 256, in <module>
2018-04-24 20:31:56     main()
2018-04-24 20:31:56   File "/tmp/ansible-test-coverage-6PITfS/coverage/ansible-playbook", line 114, in main
2018-04-24 20:31:56     args, env = injector()
2018-04-24 20:31:56   File "/tmp/ansible-test-coverage-6PITfS/coverage/ansible-playbook", line 150, in injector
2018-04-24 20:31:56     executable = find_executable(command)
2018-04-24 20:31:56   File "/tmp/ansible-test-coverage-6PITfS/coverage/ansible-playbook", line 252, in find_executable
2018-04-24 20:31:56     raise Exception('Executable "%s" not found in path: %s' % (executable, path))
2018-04-24 20:31:56 Exception: Executable "ansible-playbook" not found in path: /tmp/ansible-test-coverage-6PITfS/coverage:/root/ansible/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment