ansible-lint icon indicating copy to clipboard operation
ansible-lint copied to clipboard

False positive: hosts variable not defined

Open jrglynn2 opened this issue 8 months ago • 1 comments

Summary

False positive for undefined variable in hosts.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 24.6.0 using ansible-core:2.17.1 ansible-compat:24.6.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
  • ansible installation method: pip
STEPS TO REPRODUCE

See issue #3229 - same question.


Desired Behavior

Answer was provided - https://github.com/ansible/ansible-lint/issues/3229#issuecomment-1495990003 - but the answer is to set a default value for hosts, which I would never want to do.

Desired behavior is that we can set something in ansible-lint config to tell ansible-lint to ignore any undefined variables - either altogether, or specifically in the hosts: line

Actual Behavior

ansible-lint highlights error - The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'hosts_used' is undefined

This isn't an error - all my playbooks are designed to feed in a host as needed, on purpose. So, I should be able to tell Lint to ignore this error. Desired behavior is that we can set something in ansible-lint config to tell ansible-lint to ignore any undefined variables - either altogether, or specifically in the hosts: line

jrglynn2 avatar Jun 19 '24 20:06 jrglynn2