skip to Main Content

While running a github linter workflow on a new CentOS VM that I set up, I got the following error:

Run ansible-lint --parseable ./ansible
Traceback (most recent call last):
  File "/usr/local/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
  File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 344, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 197, in main
    initialize_options(argv[1:])
  File "/usr/local/lib/python3.9/site-packages/ansiblelint/__main__.py", line 110, in initialize_options
    options.cache_dir = get_cache_dir(options.project_dir)
  File "/usr/local/lib/python3.9/site-packages/ansible_compat/prerun.py", line 13, in get_cache_dir
    basename = project_dir.resolve().name.encode(encoding="utf-8")
AttributeError: 'str' object has no attribute 'resolve'
Error: Process completed with exit code 1.

I tried with the following package versions which all failed with the above error:

  • python3: 3.9.16
  • ansible: 8.0.0 or 6.6.0
  • ansible-compat: 4.1.2 or 2.2.7
  • ansible-core: 2.15.0 or 2.13.9
  • ansible-lint: 6.17.0 or 6.10.2

Using pip, the following dependencies were also installed:

  • flake8
  • yamllint==1.28.0
  • codespell
  • comment_parser

Is there some linter dependency or something else that I am missing?

The step within the linter job is:

 - name: 'Lint yaml - ansible, GH actions and GH workflows'
   run: yamllint -f parsable ./
   if: always()

2

Answers


  1. In my environment, downgrading ansible_compat to v3.0.1 with pip install solved the problem. From v4 on, prerun.py contains the line that gives error.

    Login or Signup to reply.
  2. Seems to be an ansible-lint bug:

    Latest ansible-lint release (v6.15.0) incompatible with latest ansible-compat (v4.0.2) · Issue #3408 · ansible/ansible-lint · GitHub

    According to the upstream developer:

    We released https://github.com/ansible/ansible-lint/releases/tag/v6.16.0 to address this issue. If you want to use older versions, you will need to manually pin-down ansible-compat version to avoid use of v4.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search