Closed alxgomz closed 2 years ago
@alxgomz I found a solution: sudo ansible-lint
.
Background: Recently I change my Ansible Collection for Kubernetes (molecule + libvirt based, https://github.com/alvistack/ansible-collection-kubernetes) to be running with sudo
during CI, so my $HOME/.cache/ansible-compat
directory now belongs to root
but not my current user. Because https://github.com/ansible/ansible-lint/blob/main/src/ansiblelint/_mockings.py#L70-L76 will create a symlink for mocking, in case directory permission error the symlink will not able to be created and so failed.
Thanks @hswong3i In my case the CI runs on linux hosts so I'm not facing the issue there. Instead it's happening on my local dev machine whe pre-commit hook kicks in. And of course I don't really to sudo git commit :)
The issue arose while I had a collections in the cache that was a folder. After I deleted it and ran lint again, it got recreated as a symlink and there's no more error. I guess that's an issue only if you migrate from env where previous versions of ansible-lint already populated the cache
@alxgomz yes I also find delete the existing cached folders from $HOME/.cache/ansible* help ;-)
I have exactly the same issue since version 6. I can reproduce it locally (Ubuntu) and on CI (Molecule lint).
Also for me removing the galaxy.yml
file resolves the issue.
Maybe a better solution with prerun: false
, e.g. https://github.com/alvistack/ansible-collection-kubernetes/commit/b265db909b52a35d61cef06e6a7fac0ce1ed0416
See https://molecule.readthedocs.io/en/latest/configuration.html?highlight=galaxy#prerun for more information.
This is not an issue with Molecule. It happens if I run ansible-lint
directly. The error occurs also via Molecule because it calls Ansible lint to lint the role.
AFAIK This bug does not reproduce with v6.2.1
For me this is still happening with v6.2.1.
@egvimo Can you remove the cache folder and recreate virtualenv? My main machine is a macos and i never seen this myself, i suspect a local "glitch" that you might have. We really need to find a way to reproduce it to be able to fix it.
It is failing on CI (Ubuntu) with the linting step of Molecule:
OSError: [Errno 22] Invalid argument: '/home/runner/.cache/ansible-compat/9c3242/collections/ansible_collections/egvimo/misc'
I've tried to remove the /home/runner/.cache/
folder in the step before. So I think it is not an an issue with local caching, although I can reproduce it locally with this repository.
Summary
When running ansible-lint on my project I get the error below after upgrading to ansible-lint 6.0.2. This seems to be related to the presence of the galaxy.yml file at the root of my project. It contains details about the playbook as per the ansible-galaxy format but the playbook itself has not been pushed to galaxy (it is just here waiting for maturity)
Issue Type
Ansible and Ansible Lint details
OS / ENVIRONMENT
MacOSX Monterey
STEPS TO REPRODUCE
Desired Behavior
Linting completes and return result
Actual Behavior
ansible-lint fails with the error bellow
Other info:
The same reproduction steps work ok on linux. Removing the
galaxy.yml
file fixes the problem.