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

Custom ansible root dir breaks requirements resolution #3863

Open
szaffarano opened this issue Oct 22, 2023 · 0 comments
Open

Custom ansible root dir breaks requirements resolution #3863

szaffarano opened this issue Oct 22, 2023 · 0 comments
Labels

Comments

@szaffarano
Copy link

szaffarano commented Oct 22, 2023

Summary

I'm using ansible-lint as part of my pre-commit hooks. Today I bumped the hooks versions (i.e. pre-commit autoupdate) and ansible-lint started to fail.

  • Pre commit config:
  - repo: https://github.com/ansible/ansible-lint
    rev: v6.21.1
    hooks:
      - id: ansible-lint
        args: [--project-dir=ansible]

Project structure

.
├── ansible
│   ├── ansible.cfg
│   ├── hosts.ini
│   ├── host_vars
│   ├── README.md
│   ├── requirements.yml
│   ├── roles
│   ├── .ansible-lint
│   └── vars
├── .pre-commit-config.yaml
└── ...

The previous version was v6.15.0 and it worked fine, but with v6.21.1 it started failing because it doesn't download the roles and collections listed in ansible/requirements.yml.

As a workaround, if I move requirements.yml to the project root directory, it works. But as I said, it was working as expected with previous versions. It seems that --project-dir=ansible is not working anymore, but on the other side, setting any value makes ansible-lint fail with the proper error message: Failed to determine a valid project_dir.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
v6.21.1
  • ansible installation method: one of source, pip, OS package
  • ansible-lint installation method: one of source, pip, OS package
STEPS TO REPRODUCE

Use the above pre-commit configuration in any ansible project located in a subfolder, depending on any collection or role.

Desired Behavior

Honor the --project-dir flag to use this value as the ansible project root directory.

Possible security bugs should be reported via email to security@ansible.com

Actual Behavior

Please give some details of what is happening.
Include a minimum complete verifiable example with:

  • minimized playbook to reproduce the error
  • the output of running ansible-lint including the command line used
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook

Related: ansible/ansible-compat#343

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

Successfully merging a pull request may close this issue.

3 participants