The current set up of my project is
/projects
/plugins
/roles/sampleRole1/...
/roles/sampleRole2/..
galaxy.yml
I want to lint each any every role that exists within "/roles" but I am having trouble figuring out a solution and running into problems.
Currently when running
ansible-lint ./roles/sampleRole/
I get
Traceback (most recent call last):
File "/opt/homebrew/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
File "/opt/homebrew/lib/python3.9/site-packages/ansiblelint/__main__.py", line 252, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/opt/homebrew/lib/python3.9/site-packages/ansiblelint/__main__.py", line 165, in main
app = get_app(offline=options.offline)
File "/opt/homebrew/lib/python3.9/site-packages/ansiblelint/app.py", line 252, in get_app
_perform_mockings()
File "/opt/homebrew/lib/python3.9/site-packages/ansiblelint/_mockings.py", line 88, in _perform_mockings
while os.readlink(link_path) != target:
OSError: [Errno 22] Invalid argument: '/Users/mjones2/.cache/ansible-compat/121e36/collections/ansible_collections/something/something
So I created a scrip that will cd into each directory and then run ansible-lint
for dir in ./roles/*/; do (cd "$dir" && ansible-lint -v); done
Although the output of this command does not show me the entire file location. Ex it will say
tasks/main.yml:19: yaml: line too long (173 > 160 characters) (yaml[line-length])
This would be hard to debug in a ci pipeline and I would rather know the exact source of the problem.
Initially, I just wanted to add a comment, because there are some questions in my head. Anyway, let's try with a resolution.
I have setup a project looking like this:
When running
ansible-lint playbooks/
oransible-lint roles/sample1/
everything works as expected. I get the errors I have put in (whitespace, name too long).Therefore, I assume that your Ansible Lint version has some issues. I am using:
If this is not feasible for you, there is also a similar option to your loop and the first comment, which will produce a readable output:
I hope this helps.