Skip to content

Instantly share code, notes, and snippets.

@zdw
Created March 19, 2021 23:31
Show Gist options
  • Save zdw/9dac6873be517479c949604c04dbfd45 to your computer and use it in GitHub Desktop.
Save zdw/9dac6873be517479c949604c04dbfd45 to your computer and use it in GitHub Desktop.
# NoTags.py
# ansible-lint rule to mark all tags as errors
from __future__ import absolute_import
from ansiblelint import AnsibleLintRule
class NoTags(AnsibleLintRule):
id = "ONF0001"
shortdesc = "Don't use tags to modify runtime behavior"
description = (
"Tags can change which tasks Ansible performs when running a role or"
"playbook, which is undesirable. Reorganize your roles to not require"
"them, optionally using setup facts or platform vars as workarounds."
)
tags = ["idiom"]
severity = "HIGH"
def matchtask(self, file, task):
# Task should not have tags
if "tags" in task:
# allow if only tag is the skip_ansible_lint tag
if task["tags"] == ["skip_ansible_lint"]:
return False
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment