summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/rules/deprecated_bare_vars.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ansiblelint/rules/deprecated_bare_vars.py')
-rw-r--r--src/ansiblelint/rules/deprecated_bare_vars.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ansiblelint/rules/deprecated_bare_vars.py b/src/ansiblelint/rules/deprecated_bare_vars.py
index 1756e92..7b1ab08 100644
--- a/src/ansiblelint/rules/deprecated_bare_vars.py
+++ b/src/ansiblelint/rules/deprecated_bare_vars.py
@@ -27,7 +27,7 @@ import sys
from typing import TYPE_CHECKING, Any
from ansiblelint.rules import AnsibleLintRule
-from ansiblelint.text import has_glob, has_jinja
+from ansiblelint.text import has_glob, has_jinja, is_fqcn_or_name
if TYPE_CHECKING:
from ansiblelint.file_utils import Lintable
@@ -66,7 +66,7 @@ class UsingBareVariablesIsDeprecatedRule(AnsibleLintRule):
# we just need to check that one variable, and not iterate over it like
# it's a list. Otherwise, loop through and check all items.
items = task[loop_type]
- if not isinstance(items, (list, tuple)):
+ if not isinstance(items, list | tuple):
items = [items]
for var in items:
return self._matchvar(var, task, loop_type)
@@ -84,7 +84,11 @@ class UsingBareVariablesIsDeprecatedRule(AnsibleLintRule):
task: dict[str, Any],
loop_type: str,
) -> bool | str:
- if isinstance(varstring, str) and not has_jinja(varstring):
+ if (
+ isinstance(varstring, str)
+ and not has_jinja(varstring)
+ and is_fqcn_or_name(varstring)
+ ):
valid = loop_type == "with_fileglob" and bool(
has_jinja(varstring) or has_glob(varstring),
)
@@ -121,4 +125,4 @@ if "pytest" in sys.modules:
failure = "examples/playbooks/rule-deprecated-bare-vars-fail.yml"
bad_runner = Runner(failure, rules=collection)
errs = bad_runner.run()
- assert len(errs) == 12
+ assert len(errs) == 11