blob: e4144a943e7aa4d6c8bd21c80a869f0a6400ca33 [file] [log] [blame]
Zack Williamsad45bf02020-03-04 21:37:20 -07001# SPDX-FileCopyrightText: © 2020 Open Networking Foundation
2# SPDX-License-Identifier: Apache-2.0
3
4# NoTags.py
5# ansible-lint rule to mark all tags as errors
6
7from __future__ import absolute_import
8from ansiblelint import AnsibleLintRule
9
10
11class NoTags(AnsibleLintRule):
12 id = "ONF0001"
13 shortdesc = "Don't use tags to modify runtime behavior"
14 description = (
15 "Tags can change which tasks Ansible performs when running a role or"
16 "playbook, which is undesirable. Reorganize your roles to not require"
17 "them, optionally using setup facts or platform vars as workarounds."
18 )
19 tags = ["idiom"]
20 severity = "HIGH"
21
Zack Williamsdac2be42021-08-19 16:14:31 -070022 def matchtask(self, file, task): # pylint: disable=W0613, R0201
Zack Williamsad45bf02020-03-04 21:37:20 -070023
24 # Task should not have tags
25 if "tags" in task:
26
27 # allow if only tag is the skip_ansible_lint tag
28 if task["tags"] == ["skip_ansible_lint"]:
29 return False
30
31 return True
32
33 return False