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 to recognize requirement files within the Molecule directory #1369
Comments
The only supported filename for requirements is You will likely have to rename the file and/or move it into a folder like You pointed to the correct source code location that determines the file types, but in this case it does not look like a bug in our patterns and more of a local ambiguity. I will likely update molecule docs as I find the example with collections.yml misleading. I am included to drop support for old requirements.yml (v1 version and only support v2, which allows both roles and collections inside) but I am not sure if that works with 2.8. If it does not, i will postpone until we drop support for 2.8 |
The same error occurs when the file is named
I strongly disagree with this suggestion. When using the dependency manager of galaxy it looks per default for a file called |
I will make a patch to recognize Keep in mind that neither molecule nor ansible-lint officially support for Ansible 2.8 and these are needed only for 2.8, a 2.9+ can make use of newer combined format. I do expect to see both making presence of ansible 2.8 an error or at least a big warning saying that no bugs related to 2.8 will be addressed. |
I believe this breaks the case where you have multiple molecule scenarios that extend a shared scenario such as in this example from molecule doc:
Example repo with multiple molecule scenarios that worked until |
Molecule does support the two latest stable ansible releases which are as of today ansible 2.8 and ansible 2.9. From the latest molecule documentation: "Molecule supports only the latest two major versions of Ansible (N/N-1), meaning that if the latest version is 2.9.x, we will also test our code with 2.8.x." |
@fgierlinger I guess I will have to add a check sooner, read https://pypi.org/project/ansible/ --- 2.10 was released in September 2020 ! -- I don't care what is the latest version shipped with a platfort distribution, ansible core project is 2.10, and the community version 3.0 already as a rc. Keep in mind that 2.8 happens to mostly work with molecule, but the tool does not offer any guarantees and any bug mentioning it will be closed right away. @boutetnico Thanks for mentioning base.yml, another special case to add for improving detection via #1374 |
As far as I know I am using the v2 requirements format whenever I use a requirements file (see https://github.com/nginxinc/ansible-role-nginx-config/blob/main/molecule/common/playbooks/oss_requirements.yml). That being said, I am very much against throwing a requirements file that is only used when running Molecule tests (it's not a real dependency) anywhere outside the Molecule directory. If that's no longer going to be allowed by Ansible Lint as valid requirements location, I can probably work around it (e.g. creating a requirements folder inside a nested Molecule directory seems to work -- |
Currently maintained are:
https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html Be aware (but you probably are) that When releasing Further, as pointed out already by other people, there has not been any official statement from ansible, that standalone roles, nor the old requirements.yml format is deprecated or will get deprecated soon. |
Summary
Ansible Lint fails to recognize requirement files within the Molecule directory.
Issue Type
Ansible and Ansible Lint details
pip
pip
OS / ENVIRONMENT
Bug can be reproduced in both MacOS environments and Ubuntu 20.04.
STEPS TO REPRODUCE
nginx_config
role from Ansible Galaxy (https://github.com/nginxinc/ansible-role-nginx-config)ansible-lint
ansible-playbook --syntax-check
).See https://github.com/nginxinc/ansible-role-nginx-config/pull/75/checks?check_run_id=1912453583#step:7:34 for a concrete example.
Desired Behaviour
Ansible Lint should detect that there is a requirements file within the Molecule directory and treat it as such. There might be some use cases where some roles are only required within a Molecule workflow and as such it makes more sense to contain the relevant requirement files within the Molecule directory. Furthermore, depending on the test case, different requirement files might make sense. Ideally, I'd like to see some regex matching for requirement files not unlike the regex matching that's available for playbooks in https://github.com/ansible-community/ansible-lint/blob/master/src/ansiblelint/config.py#L19.
Actual Behaviour
Ansible Lint fails to recognize that there might be some requirements files contained within the Molecule directory. My best guess it that this has to do with the file mappings detailed in https://github.com/ansible-community/ansible-lint/blob/master/src/ansiblelint/config.py#L15-L29.
The text was updated successfully, but these errors were encountered: