You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue resolving paths to local collections when ansible-lint is not executed in project dir. It loos like tit will not alter or change the path from collections_path with is ./.
Issue Type
Bug Report
OS / ENVIRONMENT
[root@localhost ansible]# ansible-lint --versionansible-lint 6.22.0 using ansible-core:2.15.6 ansible-compat:4.1.10 ruamel-yaml:None ruamel-yaml-clib:NoneA new release of ansible-lint is available: 6.22.0 → 6.22.1 Upgrade by running: pip install --upgrade ansible-lint
ansible installation method: pip
ansible-lint installation method: pip
STEPS TO REPRODUCE
have a local collection with collections_path = ~/.ansible/collections:/usr/share/ansible/collections:./
[root@localhost infrastructure]# ansible-lint ansible/WARNING Listing 4 violation(s) that are fatalsyntax-check[specific]: the role 'xxx.infrastructure.vault' was not found in /scm/infrastructure/ansible/ansible_collections/xxx/infrastructure/playbooks/roles:/root/.cache/ansible-compat/9fec08/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/scm/infrastructure/ansible/ansible_collections/xxx/infrastructure/playbooksansible/ansible_collections/xxx/infrastructure/playbooks/local.yml:18:15syntax-check[missing-file]: Unable to retrieve file contentsansible/playbooks/add-chart.yml:1:1 Could not find or access '/scm/infrastructure/ansible/playbooks/xxx.infrastructure.local' on the Ansible Controller.syntax-check[missing-file]: Unable to retrieve file contentsansible/playbooks/build.yml:1:1 Could not find or access '/scm/infrastructure/ansible/playbooks/xxx.infrastructure.local' on the Ansible Controller.syntax-check[missing-file]: Unable to retrieve file contentsansible/playbooks/clean-all.yml:1:1 Could not find or access '/scm/infrastructure/ansible/playbooks/xxx.infrastructure.local' on the Ansible Controller. Rule Violation Summary count tag profile rule associated tags 3 syntax-check[missing-file] min core, unskippable 1 syntax-check[specific] min core, unskippable Failed: 4 failure(s), 0 warning(s) on 43 files.A new release of ansible-lint is available: 6.22.0 → 6.22.1 Upgrade by running: pip install --upgrade ansible-lint[root@localhost infrastructure]# ansible-lint -p ansible/WARNING Listing 4 violation(s) that are fatalansible/ansible_collections/xxx/infrastructure/playbooks/local.yml:18:15: syntax-check[specific]: the role 'xxx.infrastructure.vault' was not found in /scm/infrastructure/ansible/ansible_collections/xxx/infrastructure/playbooks/roles:/root/.cache/ansible-compat/9fec08/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/scm/infrastructure/ansible/ansible_collections/xxx/infrastructure/playbooksansible/playbooks/add-chart.yml:1:1: syntax-check[missing-file]: Unable to retrieve file contentsansible/playbooks/build.yml:1:1: syntax-check[missing-file]: Unable to retrieve file contentsansible/playbooks/clean-all.yml:1:1: syntax-check[missing-file]: Unable to retrieve file contents Rule Violation Summary count tag profile rule associated tags 3 syntax-check[missing-file] min core, unskippable 1 syntax-check[specific] min core, unskippable Failed: 4 failure(s), 0 warning(s) on 43 files.A new release of ansible-lint is available: 6.22.0 → 6.22.1 Upgrade by running: pip install --upgrade ansible-lint[root@localhost infrastructure]# cd ansible/ && ansible-lint .WARNING Skipped installing collection dependencies due to running in offline mode.Passed: 0 failure(s), 0 warning(s) on 5 files. Last profile that met the validation criteria was 'production'.A new release of ansible-lint is available: 6.22.0 → 6.22.1 Upgrade by running: pip install --upgrade ansible-lint
Desired Behavior
ansible-lint -p ansible/ shall work the same as cd ansible/ && ansible-lint .
Possible security bugs should be reported via email to [email protected]
Actual Behavior
See the /scm/infrastructure/ansible missing in the failed run.
[root@localhost ansible]# ansible-lint -p . -vvvv
INFO Set ANSIBLE_COLLECTIONS_PATH=/root/.cache/ansible-compat/0cb87f/collections:/root/.ansible/collections:/usr/share/ansible/collections:/scm/infrastructure/ansible
[root@localhost infrastructure]# ansible-lint -p ansible/ -vvvv
INFO Set ANSIBLE_COLLECTIONS_PATH=/root/.cache/ansible-compat/9fec08/collections:/root/.ansible/collections:/usr/share/ansible/collections
I think that this is not a bug because when you pass -p you force ansible lint to assume a different project instead of the detected one. Different is to be expected.
I execute ansible-lint from the root dir of the project, it then traverses into a number of different roles which each have molecule files in them. It then fails on each molecule/prepare.yml saying syntax-check[specific]: the role 'xyz.common.rolename' was not found in <big list of search locations> . Yet this collection has already been fetched as apart of the intilization. To get it to run I have to use --exclude molecule/*/prepare.yml otherwise it keeps failing on the syntax-check stage.
But ansible-lint insists on going up to the location of the .git folder rather than the parent directory of the config file (as seen from the log message Identified <repo root> as project root due .git directory.
Has anyone found a work-around?
It's annoying because pre-commit doesn't easily allow changing the CWD when running ansible-lint.
Summary
Issue resolving paths to local collections when ansible-lint is not executed in project dir. It loos like tit will not alter or change the path from collections_path with is ./.
Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
have a local collection with collections_path = ~/.ansible/collections:/usr/share/ansible/collections:./
Desired Behavior
ansible-lint -p ansible/ shall work the same as cd ansible/ && ansible-lint .
Possible security bugs should be reported via email to
[email protected]
Actual Behavior
See the /scm/infrastructure/ansible missing in the failed run.
Related: ansible/ansible-compat#343
The text was updated successfully, but these errors were encountered: