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
Using groups['{group_name}'] in serial gets linted as an error:
The field 'serial' has an invalid value, which includes an undefined variable. The error was: 'dict object' has no attribute '{group_name}' ansible-lint(syntax-check[specific])
Issue Type
Bug Report
OS / ENVIRONMENT
$ ansible-lint --versionansible-lint 24.6.1 using ansible-core:2.17.1 ansible-compat:24.6.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.7
$ ansible-lint playbooks/test.yamlWARNING Listing 1 violation(s) that are fatalsyntax-check[specific]: The field 'serial' has an invalid value, which includes an undefined variable. The error was: 'dict object' has no attribute 'group_name'playbooks/test.yaml:2:3 Rule Violation Summary count tag profile rule associated tags 1 syntax-check[specific] min core, unskippableFailed: 1 failure(s), 0 warning(s) on 1 files.
N.B. I get the same error in the root repository (/home/dcasella/{REDACTED_PATH} from the log above). The example provided was tested inside a /test directory.
The text was updated successfully, but these errors were encountered:
I believe this occurs because underneath the covers, the syntax-check performed is done using localhost as the inventory. This is despite what the documentation says on syntax-check violations.
Our linter runs ansible-playbook --syntax-check on all playbooks, and if any of these reports a syntax error, this stops any further processing of these files.
This error cannot be disabled due to being a prerequisite for other steps. You can exclude these files from linting, but it is better to make sure they can be loaded by Ansible. This is often achieved by editing the inventory file and/or ansible.cfg so ansible can load required variables.
Summary
Using
groups['{group_name}']
inserial
gets linted as an error:Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
ansible.cfg
:inventories/D/on-prem.yaml
:playbooks/test.yaml
:Run commands (both work):
Linter error:
Desired Behavior
No linter error.
Actual Behavior
Linter error:
N.B. I get the same error in the root repository (
/home/dcasella/{REDACTED_PATH}
from the log above). The example provided was tested inside a/test
directory.The text was updated successfully, but these errors were encountered: