Skip to content
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

ansible-lint is suddenly capped to 32 --exclude paths #1574

Closed
klausenbusk opened this issue May 21, 2021 · 2 comments · Fixed by #1578
Closed

ansible-lint is suddenly capped to 32 --exclude paths #1574

klausenbusk opened this issue May 21, 2021 · 2 comments · Fixed by #1578
Labels

Comments

@klausenbusk
Copy link

Summary

With this #1557 change, ansible-lint is now capped to 32 --exclude paths when running outside a Git repository or when Git isn't installed (ex: when running in GitLab CI, CI log).

Issue Type
  • Bug Report
Ansible and Ansible Lint details
$ ansible [core 2.11.0] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/kristian/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/kristian/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.5 (default, May 12 2021, 17:14:51) [GCC 10.2.0]
  jinja version = 3.0.1
  libyaml = True
$ ansible-lint --version
ansible-lint 5.0.10 using ansible 2.11.0
  • ansible installation method: OS package
  • ansible-lint installation method: OS package
OS / ENVIRONMENT

Arch Linux

STEPS TO REPRODUCE

Run ansible-lint with more than 32 --exclude.

Desired Behaviour

ansible-lint should --exclude all the specified files.

Actual Behaviour
$ ansible-lint $(printf -- "--exclude %s " {1..33})
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 33, in <module>
    sys.exit(load_entry_point('ansible-lint==5.0.10', 'console_scripts', 'ansible-lint')())
  File "/usr/lib/python3.9/site-packages/ansiblelint/__main__.py", line 292, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/usr/lib/python3.9/site-packages/ansiblelint/__main__.py", line 229, in main
    result = _get_matches(rules, options)
  File "/usr/lib/python3.9/site-packages/ansiblelint/runner.py", line 184, in _get_matches
    lintables = ansiblelint.utils.get_lintables(options=options, args=options.lintables)
  File "/usr/lib/python3.9/site-packages/ansiblelint/utils.py", line 805, in get_lintables
    for filename in discover_lintables(options):
  File "/usr/lib/python3.9/site-packages/ansiblelint/file_utils.py", line 230, in discover_lintables
    out = WcMatch('.', exclude_pattern=exclude_pattern, flags=RECURSIVE).match()
  File "/usr/lib/python3.9/site-packages/wcmatch/wcmatch.py", line 153, in __init__
    self._compile(self.pattern_file, self.pattern_folder_exclude)
  File "/usr/lib/python3.9/site-packages/wcmatch/wcmatch.py", line 219, in _compile
    self.folder_exclude_check = self._compile_wildcard(folder_exclude_pattern, self.dir_pathname)
  File "/usr/lib/python3.9/site-packages/wcmatch/wcmatch.py", line 202, in _compile_wildcard
    return _wcparse.compile(pattern, flags, self.limit) if pattern else None
  File "/usr/lib/python3.9/site-packages/wcmatch/_wcparse.py", line 646, in compile
    raise PatternLimitException("Pattern limit exceeded the limit of {:d}".format(limit))
wcmatch._wcparse.PatternLimitException: Pattern limit exceeded the limit of 32
@ssbarnea
Copy link
Member

I need to warn you that calling a tool like this is prone to errors, there is a patch that is increasing the limit to 256 but I do not plan to increase it further. If you still encounter it you will have to find another way to call the tool. You are likely to exceed operating system limits anyway.

ssbarnea added a commit that referenced this issue May 22, 2021
ssbarnea added a commit that referenced this issue May 22, 2021
ssbarnea added a commit that referenced this issue May 22, 2021
@klausenbusk
Copy link
Author

I need to warn you that calling a tool like this is prone to errors, there is a patch that is increasing the limit to 256 but I do not plan to increase it further.

I know there is a upper limit and 256 sounds fair. We are only excluding ~40 (vault) files at the moment and I don't expect it to increase very much. As kinda discussed here: #1350 (comment), ideally --exclude should support globs but it isn't a high priority and ansible-lint $(printf -- "--exclude %s " */*/vault_*) works good enough for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants