diff --git a/.config/dictionary.txt b/.config/dictionary.txt index 447895a921..f73396f59a 100644 --- a/.config/dictionary.txt +++ b/.config/dictionary.txt @@ -67,6 +67,7 @@ bracketsmatchtestfile buildinfo buildset builtins +cacheable cachier capfd caplog diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 9931e4fe65..3667ea1f9f 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -59,7 +59,7 @@ jobs: WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 800 + PYTEST_REQPASS: 801 steps: - name: Activate WSL1 if: "contains(matrix.shell, 'wsl')" diff --git a/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml b/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml new file mode 100644 index 0000000000..23113ebb5d --- /dev/null +++ b/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml @@ -0,0 +1,5 @@ +--- +- name: cacheable_set_fact | Using set_fact with cacheable + ansible.builtin.set_fact: + var_naming_pattern_fact: bar + cacheable: true diff --git a/src/ansiblelint/rules/var_naming.py b/src/ansiblelint/rules/var_naming.py index 02870c5008..771916ab30 100644 --- a/src/ansiblelint/rules/var_naming.py +++ b/src/ansiblelint/rules/var_naming.py @@ -229,7 +229,9 @@ def matchtask( # noqa: C901 # If the task uses the 'set_fact' module if ansible_module == "set_fact": for key in filter( - lambda x: isinstance(x, str) and not x.startswith("__"), + lambda x: isinstance(x, str) + and not x.startswith("__") + and x != "cacheable", task["action"].keys(), ): match_error = self.get_var_naming_matcherror(key, prefix=prefix) @@ -349,3 +351,10 @@ def test_var_naming_with_include_tasks_and_vars() -> None: result = run_ansible_lint(role_path) assert result.returncode == RC.SUCCESS assert "var-naming" not in result.stdout + + def test_var_naming_with_set_fact_and_cacheable() -> None: + """Test with include tasks and vars.""" + role_path = "examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml" + result = run_ansible_lint(role_path) + assert result.returncode == RC.SUCCESS + assert "var-naming" not in result.stdout diff --git a/src/ansiblelint/schemas/__store__.json b/src/ansiblelint/schemas/__store__.json index d6e802e909..f56a582ba1 100644 --- a/src/ansiblelint/schemas/__store__.json +++ b/src/ansiblelint/schemas/__store__.json @@ -36,7 +36,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/molecule.json" }, "playbook": { - "etag": "352673fc239ca58ad41a2e5d160ff24d5714f91d0f082fda5a2204ee11880f64", + "etag": "9f6baaa61cc2bfaf32d00af12ef6dd0e8ca3dd3bb94581cabb66a92795d8f4e6", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json" }, "requirements": { @@ -52,7 +52,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-rulebook/main/ansible_rulebook/schema/ruleset_schema.json" }, "tasks": { - "etag": "6d30ce47562d7fbed2cebf1385527946265c8153be657b9b2d67956777f39936", + "etag": "f9fbc0855680d1321fa3902181131d73838d922362d8dfb85a4f59402240cc07", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/tasks.json" }, "vars": {