-
Notifications
You must be signed in to change notification settings - Fork 664
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
Current working directory affects execution environment generated on prerun #1654
Comments
ansible#1654) Signed-off-by: Xabier Napal <[email protected]>
That is indeed a bug and you explained it well: as ansible-lint uses the concept of |
So, if I have understood it correctly, the directory choice for the
I'm going to submit a PR with the required |
You described the order it perfectly. |
ansible#1654) Signed-off-by: Xabier Napal <[email protected]>
I think this was fixed by #1661 - please let me know if that is not true so we can reopen it. |
Summary
Not sure if this should be a bug, a proposal or even if it is the intended behaviour.
When running on a collection repository,
ansible-lint
caches it on a~/.cache/ansible-lint/<HASH>/collections/ansible_collections
directory as part of theprerun
process. When being launched on a directory other than the root one, such as a role, it does not detect that the role is part of a collection, and only caches the role directory, not the collection one.I think that this behaviour is wrong because
ansible-lint
always tries to find the project root directory and work from there, except during theprerun
. In fact, the hash is generated based on the root directory even when being launched on a subdirectory. After #1483,prerun
was made public so other packages can use it, and this can cause issues to those packages.I already have a PR ready to be submitted in case this is accepted.
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
Can be reproduced both in
ansible-lint
5.0.12
and5.1.0a1
.STEPS TO REPRODUCE
Linting from the repository root detects it as a collection (as it finds a
galaxy.yml
file) and sets theANSIBLE_COLLECTIONS_PATH
environment variable:Executing in a role directory (or, any other directory other than the root) also includes the
ANSIBLE_COLLECTIONS_PATH
environment variable, as the cached directory already contains thecollections/ansible_collections
directory:After removing the cache, running from a diferent directory does not treat the repository as a collection one:
Desired Behaviour
Behaviour should be deterministic instead of depending on execution path and cache contents. It should determine the repository type based on where the
.ansible-lint
file is located and not on the current directory.Actual Behaviour
Follow the steps to reproduce. Current working directory and previous executions affect the environment of the
prerun
process.The text was updated successfully, but these errors were encountered: