8000 ansible-lint cluttering workspace with .ansible folders · Issue #4533 · ansible/ansible-lint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ansible-lint cluttering workspace with .ansible folders #4533

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

Open
fbermel opened this issue Feb 24, 2025 · 11 comments
Open

ansible-lint cluttering workspace with .ansible folders #4533

fbermel opened this issue Feb 24, 2025 · 11 comments
Labels

Comments

@fbermel
Copy link
fbermel commented Feb 24, 2025
Summary

Installaing the latest version of ansible lint with pip install ansible-dev-tools leads to ansible-lint creating .ansible folders relative to the path where it was launched from.

Issue Type
  • Bug Report
OS / ENVIRONMENT
> ansible-lint --version
ansible-lint 25.1.3 using ansible-core:2.18.2 ansible-compat:25.1.3 ruamel-yaml:0.18.10 ruamel-yaml-clib:None
> uname -a
23.6.0 Darwin Kernel Version 23.6.0: Thu Dec 19 20:47:53 PST 2024; root:xnu-10063.141.1.703.2~1/RELEASE_ARM64_T6030 arm64
> sw_vers
ProductName:            macOS
ProductVersion:         14.7.4
BuildVersion:           23H42
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
> cd ~/git/bml/infra_reloaded/
> ls
.git             .gitignore       .password        ansible.cfg      inventory        plays            requirements.txt requirements.yml roles 
> python -m venv .venv
> . .venv/bin/activate
> pip install --no-cache --quiet ansible-dev-tools

[notice] A new release of pip is available: 24.2 -> 25.0.1
[notice] To update, run: pip install --upgrade pip
> ls .ansible
ls: .ansible: No such file or directory
> ansible-lint --version
ansible-lint 25.1.3 using ansible-core:2.18.2 ansible-compat:25.1.3 ruamel-yaml:0.18.10 ruamel-yaml-clib:None
> ls .ansible
.lock       collections roles
Desired Behavior

ansible-lint should not create .ansible folders in the directory it's launched from.

Actual Behavior

ansible-lint creates a .ansible folder even if it's just ran with the --version flag (Also see "STEPS TO REPRODUCE")

> ls .ansible
ls: .ansible: No such file or directory
> ansible-lint --version
ansible-lint 25.1.3 using ansible-core:2.18.2 ansible-compat:25.1.3 ruamel-yaml:0.18.10 ruamel-yaml-clib:None
> ls .ansible
.lock       collections roles

This is especially annoying when using it for linting inside an editor like neovim because it pollutes the workspace with these directories.

@fbermel fbermel added bug new Triage required labels Feb 24, 2025
@fbermel fbermel changed the title ansible-lint cluttering workspace witrh .ansible folders ansible-lint cluttering workspace with .ansible folders Feb 24, 2025
@monsdar
Copy link
monsdar commented Feb 26, 2025

This happens in VSCode with enabled Ansible plugin as well. As soon as I open a .yml file in any of my workspaces repos I'll get an empty .ansible/.lock file. Even if the yml does not contain any Ansible related data.

$ ansible-lint --version
ansible-lint 25.1.3 using ansible-core:2.17.8 ansible-compat:25.1.4 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
WARNING  Project directory /.ansible cannot be used for caching as it is not writable.
WARNING  Using unique temporary directory /tmp/.ansible-0aaa for caching.

@alisonlhart alisonlhart removed the new Triage required label Feb 26, 2025
@Thulium-Drake
Copy link

To add to the list of annoyances, it also actively breaks ansible-sign, and no, this issue cannot be worked around by excluding the .ansible folder in the configuration 😢

apt$ ansible-sign project gpg-sign .
Traceback (most recent call last):
  File "/home/ansible/.local/bin/ansible-sign", line 8, in <module>
    sys.exit(run())
             ~~~^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/cli.py", line 374, in run
    return main(sys.argv[1:])
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/cli.py", line 364, in main
    exitcode = cli.run_command()
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/cli.py", line 46, in run_command
    return self.args.func()
           ~~~~~~~~~~~~~~^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/cli.py", line 321, in gpg_sign
    checksum_file_contents = self._generate_checksum_manifest()
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/cli.py", line 161, in _generate_checksum_manifest
    manifest = checksum.generate_gnu_style()
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/checksum/base.py", line 119, in generate_gnu_style
    calculated = self.calculate_checksums_from_root(verifying=False)
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/checksum/base.py", line 147, in calculate_checksums_from_root
    for path in self.differ.list_files(verifying=verifying):
                ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/checksum/differ/base.py", line 51, in list_files
    gathered = self.gather_files(verifying=verifying)
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/ansible_sign/checksum/differ/distlib_manifest.py", line 42, in gather_files
    manifest.process_directive(line)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/distlib/manifest.py", line 163, in process_directive
    if not self._include_pattern(pattern, anchor=False):
           ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/distlib/manifest.py", line 280, in _include_pattern
    self.findall()
    ~~~~~~~~~~~~^^
  File "/home/ansible/.local/share/pipx/venvs/ansible-sign/lib64/python3.13/site-packages/distlib/manifest.py", line 79, in findall
    stat = os.stat(fullname)
OSError: [Errno 40] Too many levels of symbolic links: '/home/ansible/roles/apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt/.ansible/roles/thulium_drake.apt'

@chazragg
Copy link

Have you had any luck with downgrading ansible-lint ? i tried version 24.9 after a colleague confirmed that they were not getting the issue but I've had no luck, it seems to be a persistent issue on my machine now across multiple repos / lint versions.

@bendwyer
Copy link
bendwyer commented Feb 27, 2025

@chazragg I just finished testing this - it's because of changes to ansible-compat. Assuming pip:

pip uninstall -y ansible-compat ansible-lint molecule
pip install "ansible-compat==24.10.0" ansible-lint molecule

This will install an ansible-compat version that doesn't use the annoying .ansible folder "feature", but it restricts your ansible-lint and molecule versions to 25.1.0. Not sure if this is ultimately what you want.

@Thulium-Drake
Copy link

Specific for ansible-sign I just made this function in my shell when signing my code:

anssign () 
{ 
    rm -rf .ansible
    ansible-sign project gpg-sign .;
    git add .ansible-sign
}

@hille721
Copy link
Contributor

Thanks for the workaround @bendwyer, already went ~ an hour through the docs as I thought I just configured something wrongly

@r-pufky
Copy link
r-pufky commented Mar 2, 2025

Specific for ansible-sign I just made this function in my shell when signing my code:

anssign () 
{ 
    rm -rf .ansible
    ansible-sign project gpg-sign .;
    git add .ansible-sign
}

Just be careful of disk thrashing here. My .ansible directories were 2.5GB each, per role directory.

Workaround from @bendwyer works great, and also solves yamllint vomiting linting errors all over itself because of imported collections that violate yamllint standards.

@FlorianLaunay
Copy link
FlorianLaunay commented Apr 4, 2025

I think we are facing a regression due to ansible/ansible-compat#457

@ssbarnea any idea?

My ANSIBLE_HOME is a writable directory but ansible-compat creates a .ansible dir in my project folder

@ElectricWeasel
Copy link

Any update on this? I cannot easily downgrade ansible-compat because is a brew provided bundle... Maybe we should open issue for upstream project, but I'm in lack of detailed knowledge how describe....

@sibebleuze
Copy link

I can confirm that I'm seeing the same issue (on MacOS if that has any relevance).
I have tried ansible-lint 25.1.0 and 25.1.1, where the former does not have the issue while the latter does.
The difference in ansible-compat version between those is 24.10.0 vs 25.1.1 (mentioning this since ansible-compat has been suggested above as possible source of the issue, which I think might be right on the money).


Since it took me a while to install an older version using homebrew, I'll list the command to install this:
brew install --formula -s ansible-lint.rb
The ansible-lint.rb file is downloaded from the homebrew-core repo: 25.1.0 and 25.1.1
I followed this up with brew pin ansible-lint so I'm not bothered with this again until this issue has been resolved.

@tolland
Copy link
tolland commented Apr 21, 2025

a workaroud is to create a wrapper for ansible-lint with

ansible-lint "$@"
find .ansible -depth -type d -empty -delete

or something along those lines, probably with some more defensive checks first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

0