You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a playbook imports another playbook via import_playbook ansible-lint checks if that playbook exists. It does this by calling self.app.runtime.has_playbook
However, has_playbook actually does more than check whether the playbook exists. It also calls proc = self.run(["ansible-playbook", "--syntax-check", playbook], cwd=basedir). This means that has_playbook fails if there are syntax errors in the imported playbook
This in turn means that the ansible-lint error msg = f"Failed to find {v} playbook." is inaccurate. The playbook we are trying to import may very well exist but with invalid syntax
Issue Type
Bug Report
OS / ENVIRONMENT
This happens in both the latest code from GitHub and the version my team currently use
ansible-lint --versionansible-lint 24.7.1.dev0 using ansible-core:2.17.1 ansible-compat:24.7.0 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8You are using a pre-release version of ansible-lint.
ansible-lint --versionansible-lint 24.5.0 using ansible-core:2.16.7 ansible-compat:24.6.0 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
ansible installation method: pip
ansible-lint installation method: pip or source
STEPS TO REPRODUCE
Given a playbook that imports from a collection that we don't have:
web.yml:
---
- name: Web servershosts: role_web_serversroles:
- example.server.nginx
This fails ansible-playbook --syntax-check web.yml, which is expected
If we then try and use this playbook within linux.yml:
---
- import_playbook: web.yml
This fails on ansible-lint with ERROR Failed to find web.yml playbook. because of the failing syntax checks
Desired Behavior
ansible-lint should report something more useful than Failed to find web.yml playbook.
Perhaps it could tell us about the syntax error instead of claiming it couldn't find the imported playbook
Actual Behavior
It tells us Failed to find web.yml playbook. which makes us go searching for why it can't find the playbook
The text was updated successfully, but these errors were encountered:
Summary
When a playbook imports another playbook via
import_playbook
ansible-lint checks if that playbook exists. It does this by callingself.app.runtime.has_playbook
However,
has_playbook
actually does more than check whether the playbook exists. It also callsproc = self.run(["ansible-playbook", "--syntax-check", playbook], cwd=basedir)
. This means thathas_playbook
fails if there are syntax errors in the imported playbookThis in turn means that the ansible-lint error
msg = f"Failed to find {v} playbook."
is inaccurate. The playbook we are trying to import may very well exist but with invalid syntaxIssue Type
OS / ENVIRONMENT
This happens in both the latest code from GitHub and the version my team currently use
STEPS TO REPRODUCE
Given a playbook that imports from a collection that we don't have:
web.yml:
This fails
ansible-playbook --syntax-check web.yml
, which is expectedIf we then try and use this playbook within linux.yml:
This fails on
ansible-lint
withERROR Failed to find web.yml playbook.
because of the failing syntax checksDesired Behavior
ansible-lint
should report something more useful thanFailed to find web.yml playbook.
Perhaps it could tell us about the syntax error instead of claiming it couldn't find the imported playbook
Actual Behavior
It tells us
Failed to find web.yml playbook.
which makes us go searching for why it can't find the playbookThe text was updated successfully, but these errors were encountered: