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 5.0.0 fails to find roles in directory #1336

Closed
Diaoul opened this issue Feb 10, 2021 · 6 comments
Closed

ansible-lint 5.0.0 fails to find roles in directory #1336

Diaoul opened this issue Feb 10, 2021 · 6 comments
Labels

Comments

@Diaoul
Copy link

Diaoul commented Feb 10, 2021

Summary

Ansible lint 5.0.0 fails to find roles under another directory, e.g.:

ansible
  |--- inventory
  |--- playbooks
  |--- roles
.ansible-lint
.yamllint
ansible.cfg

Relevant part of ansible.cfg:

[defaults]
inventory  = ./ansible/inventory
roles_path = ./ansible/roles
Issue Type
  • Bug Report
Ansible and Ansible Lint details
ansible --version
ansible 2.10.5
  config file = /xxxx/project/ansible.cfg
  configured module search path = ['/xx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /xx/project/.venv/lib/python3.9/site-packages/ansible
  executable location = /xx/project/.venv/bin/ansible
  python version = 3.9.1 (default, Feb  6 2021, 06:49:13) [GCC 10.2.0]
ansible-lint --version
ansible-lint 5.0.0
  • ansible installation method: pip,
  • ansible-lint installation method: pip
OS / ENVIRONMENT

Arch Linux

STEPS TO REPRODUCE

Any directory structure where roles are not under cwd

Desired Behaviour

Roles path is found and correclty set.
Same behavior as 4.3.7 which worked fine.
Follow ansible.cfg roles_path definition.

Actual Behaviour

Roles path not found.

@Diaoul Diaoul added the bug label Feb 10, 2021
@Diaoul
Copy link
Author

Diaoul commented Feb 10, 2021

With this, ansible-lint runs as expected:

ANSIBLE_ROLES_PATH=ansible/roles ansible-lint

@ssbarnea
Copy link
Member

I think this bug was fixed by #1361

@pgassmann
Copy link

pgassmann commented Feb 17, 2021

@ssbarnea Version 5.0.1 does not yet work as expected. it does not load the values from the local ansible.cfg.

I have a ansible.cfg file in the current project directory which contains:

[defaults]
roles_path = roles_galaxy:roles
$ ansible-lint playbooks/*
Added ANSIBLE_ROLES_PATH=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles
Loading custom .yamllint config file, this extends our internal yamllint config.
WARNING  Listing 1 violation(s) that are fatal
internal-error: the role 'jnv.unattended-upgrades' was not found in /path/to/project-ansible/playbooks/roles:/home/pgassmann/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles://path/to/project-ansible/roles:/path/to/project-ansible/playbooks
playbooks/site.yml:12:7 ERROR! the role 'jnv.unattended-upgrades' was not found in /path/to/project-ansible/playbooks/roles:/home/pgassmann/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/path/to/project-ansible/roles:/path/to/project-ansible/playbooks

$ ansible-lint --version
ansible-lint 5.0.1

I configured .ansible-lint.yml with offline: true

ansible loads the values correctly:

$ ansible -m debug -a msg="{{ lookup('config', 'DEFAULT_ROLES_PATH')}}" localhost
localhost | SUCCESS => {
    "msg": [
        "/path/to/project-ansible/roles_galaxy",
        "/path/to/project-ansible/roles"
    ]
}

@Diaoul
Copy link
Author

Diaoul commented Feb 17, 2021

Same here. I am able to reproduce the same bug under the same conditions of my initial ticket with 5.0.1.

@pgassmann
Copy link

@ssbarnea Can you reopen this and check?

@ssbarnea
Copy link
Member

I am aware of this bug and there is no need to reopen because we have #1375 -- It is a known issue that ansible.cfg settings are ignored,

At this moment if "roles" folder is found at root of repo, is automatically added to the path, but if you have other paths you must continue to define ANSIBLE_ROLES_PATH variable with their locations before calling the linter, at least until we fix the configuration loading. If someone makes a pull request to fix this I will be more than happy to help shipping the fix.

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

No branches or pull requests

3 participants