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
5.0.0: playbooks may fail to find current standalone galaxy role #1329
Comments
That is because you are inside a standalone galaxy role repository which you did not package and install, so Ansible itself fails to find the role. The linter now relies on ansible-playbook --syntax-check results. For collections this was sorted as we detect their presence and install them in a special location before running. I see that not as a regression but more of a side effect of doing a better testing. |
Any workaround for this ? Sometimes we want to execute the lint on the playbook but not on the roles used by this playbook. In particular when the roles are developed by others ... I tried the options below without any success ... |
I'm encountering the same issue with ansible-lint 5.0.0, it fails to find roles mentioned in my I do not use Galaxy, directory structure is simple |
@sio You are right, molecule does some magic with paths order to help ansible find not-installed-yet roles. Ansible-lint does something too, but not the same, I will try to address this case for the next patch. |
@geerlingguy Here is a question that you should answer yourself first: how do you expect this role to be consumed? Is this a galaxy standalone role or something else? If is a standalone role we do expect it to be installed as a If you read https://galaxy.ansible.com/docs/contributing/creating_role.html#role-metadata you can find no reference of using the author field for mentioning the prefix/name. In fact the example include "your name" which is clearly not a valid value for this. This means that given a cloned role repository, we cannot infer the prefix to be added to the role but we do know for sure that in production the role would end-up being installed with a prefix, if installed from galaxy. I do expect molecule playbooks to make use of full role import name, as they are supposed to match production usage, but we cannot determine that name. One workaround that you could use would be to add a symlink In the absence of any feedback from Galaxy team, I am afraid I cannot do anything to remediate this, because the problem reported is purely related to galaxy-roles. |
Also bit by this, strange that Ansible-lint now is looking for roles when run under Molecule... |
Not really strange, is expected and caused by use of ansible syntax check. You either assure you have the roles or mock them (see mock_roles option). Mentioning roles dependencies inside a requirements.yml is another way to assure they are installed (in an isolated location, not the common ansible path). |
Yeah it is strange because workflows where you don't expect the roles to be present are now broken. I don't want to edit 20 role molecule configurations to download the role itself or wire up a mocked role configuration for so many roles. For now, I am just running a |
Identify when run with a standalone galaxy roles and attempt to make them available. This change may produce a specific error when 'author' field inside galaxy_info is missing or not matching namespace requirements. Fixes: #1329
Identify when run with a standalone galaxy roles and attempt to make them available. This change may produce a specific error when 'author' field inside galaxy_info is missing or not matching namespace requirements. Fixes: #1329
Identify when run with a standalone galaxy roles and attempt to make them available. This change may produce a specific error when 'author' field inside galaxy_info is missing or not matching namespace requirements. Fixes: #1329
Identify when run with a standalone galaxy roles and attempt to make them available. This change may produce a specific error when 'author' field inside galaxy_info is missing or not matching namespace requirements. Fixes: #1329
@ssbarnea - It seems like the fix isn't working, at least in the role I just tested it under: https://github.com/geerlingguy/ansible-role-mysql/runs/1922461996#step:5:17 |
Same here, ansible-lint from git master can not find the role mentioned in CI log: https://gitlab.com/sio/ci-with-molecule-git/-/jobs/1038564970#L430 (see line 430) |
Issue [1329] was closed without a real fix, so we will just tell linter to ignore files under molecule/ directory altogether. [1329]: ansible/ansible-lint#1329
I use ansible-lint during development of standalone galaxy ansible roles, with ansible-lint in pre-commit. @ssbarnea closed this bug, but v5.0.7 still fails in the use-case described. A workaround for pre-commit: - repo: https://github.com/ansible-community/ansible-lint.git
rev: v4.3.7
hooks:
- id: ansible-lint
files: \.(yaml|yml)$ |
Mocking workaround: create a config file in the parent directory:
And create a script with the role in the parent directory #!/usr/bin/env ansible-lint
---
# This playbook for ansible-lint
- name: ansible-lint
hosts: localhost
connection: local
gather_facts: false
become: false
roles:
- role_to_lint |
Summary
Since upgrading to 5.0.0, none of my roles seem to be able to complete their CI tests.
I have modified my
pip3
install process in CI to also install eitheransible-base
oransible
, but even with that, I'm getting the error message:Issue Type
Ansible and Ansible Lint details
(Latest as installed via pip3 in CI environment)
OS / ENVIRONMENT
GitHub Actions
STEPS TO REPRODUCE
See: https://github.com/geerlingguy/ansible-role-mysql/runs/1868407331?check_suite_focus=true#step:5:18
Desired Behaviour
ansible-lint should not require any special modifications to my role to make it lint-able?
Actual Behaviour
My roles are not able to be linted.
The text was updated successfully, but these errors were encountered: