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 fails when running outside a Git repository with --exclude #1565

Closed
klausenbusk opened this issue May 21, 2021 · 0 comments · Fixed by #1570
Closed

ansible-lint fails when running outside a Git repository with --exclude #1565

klausenbusk opened this issue May 21, 2021 · 0 comments · Fixed by #1570
Labels

Comments

@klausenbusk
Copy link

klausenbusk commented May 21, 2021

Summary

Running ansible-lint outside a Git repository with --exclude results in a TypeError: sequence item 0: expected str instance, PosixPath found error.

Context: We are running ansible-lint in GitLab CI in a Docker image without Git installed, this causes the code-path for "running outside Git" to be run which fails when combined with --exclude (CI log).

Issue Type
  • Bug Report
Ansible and Ansible Lint details
$ ansible --version
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.9 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 outside a Git repository with --exclude

Desired Behaviour

ansible-lint should do its thing and don't explode.

Actual Behaviour
$ cd /
$ ansible-lint --exclude 123
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 33, in <module>
    sys.exit(load_entry_point('ansible-lint==5.0.9', 'console_scripts', 'ansible-lint')())
  File "/usr/lib/python3.9/site-packages/ansiblelint/__main__.py", line 283, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/usr/lib/python3.9/site-packages/ansiblelint/__main__.py", line 220, 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 228, in discover_lintables
    exclude_pattern = "|".join(options.exclude_paths)
TypeError: sequence item 0: expected str instance, PosixPath found
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.

1 participant