mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-25 22:30:42 +00:00
deprecate the use of 'skip_ansible_lint'
This commit is contained in:
parent
8cc9583949
commit
69fe81a9b7
@ -1,3 +1,9 @@
|
|||||||
|
- DEPRECATE
|
||||||
|
- the tag 'skip_ansible_lint' to skip tasks is deprecated
|
||||||
|
use 'skip_ansible_later' instead
|
||||||
|
- ENHANCEMENT
|
||||||
|
- add a non-enforcement rule for deprecated features
|
||||||
|
if you use a custom standards file you may have to enable `check_deprecate`
|
||||||
- BUGFIX
|
- BUGFIX
|
||||||
- ANSIBLE0010 - allow `shell` module if `args.executable` is used
|
- ANSIBLE0010 - allow `shell` module if `args.executable` is used
|
||||||
as this parameter is no longer support by command module
|
as this parameter is no longer support by command module
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Example standards definition."""
|
"""Example standards definition."""
|
||||||
|
|
||||||
|
from ansiblelater.rules.deprecated import check_deprecated
|
||||||
from ansiblelater.rules.ansiblefiles import check_become_user
|
from ansiblelater.rules.ansiblefiles import check_become_user
|
||||||
from ansiblelater.rules.ansiblefiles import check_braces_spaces
|
from ansiblelater.rules.ansiblefiles import check_braces_spaces
|
||||||
from ansiblelater.rules.ansiblefiles import check_command_has_changes
|
from ansiblelater.rules.ansiblefiles import check_command_has_changes
|
||||||
@ -27,6 +28,15 @@ from ansiblelater.rules.yamlfiles import check_yaml_hyphens
|
|||||||
from ansiblelater.rules.yamlfiles import check_yaml_indent
|
from ansiblelater.rules.yamlfiles import check_yaml_indent
|
||||||
from ansiblelater.standard import Standard
|
from ansiblelater.standard import Standard
|
||||||
|
|
||||||
|
deprecated_features = Standard(
|
||||||
|
dict(
|
||||||
|
id="ANSIBLE9999",
|
||||||
|
name="Deprecated features should not be used",
|
||||||
|
check=check_deprecated,
|
||||||
|
types=["playbook", "task", "handler"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
tasks_should_be_separated = Standard(
|
tasks_should_be_separated = Standard(
|
||||||
dict(
|
dict(
|
||||||
id="ANSIBLE0001",
|
id="ANSIBLE0001",
|
||||||
@ -296,6 +306,7 @@ standards = [
|
|||||||
literal_bool_should_be_formatted,
|
literal_bool_should_be_formatted,
|
||||||
use_become_with_become_user,
|
use_become_with_become_user,
|
||||||
use_spaces_around_filters,
|
use_spaces_around_filters,
|
||||||
|
deprecated_features,
|
||||||
# Lint
|
# Lint
|
||||||
files_should_not_contain_unnecessarily_empty_lines,
|
files_should_not_contain_unnecessarily_empty_lines,
|
||||||
files_should_be_indented,
|
files_should_be_indented,
|
||||||
|
21
ansiblelater/rules/deprecated.py
Normal file
21
ansiblelater/rules/deprecated.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"""Checks related to ansible specific best practices."""
|
||||||
|
|
||||||
|
from ansiblelater.command.candidates import Error
|
||||||
|
from ansiblelater.command.candidates import Result
|
||||||
|
from ansiblelater.utils.rulehelper import get_normalized_tasks
|
||||||
|
|
||||||
|
|
||||||
|
def check_deprecated(candidate, settings):
|
||||||
|
tasks, errors = get_normalized_tasks(candidate, settings, full=True)
|
||||||
|
description = "'{old}' is deprecated and should not be used anymore. Use '{new}' instead."
|
||||||
|
|
||||||
|
if not errors:
|
||||||
|
for task in tasks:
|
||||||
|
if "skip_ansible_lint" in task.get("tags"):
|
||||||
|
errors.append(
|
||||||
|
Error(
|
||||||
|
task["__line__"],
|
||||||
|
description.format(old="skip_ansible_lint", new="skip_ansible_later")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return Result(candidate.path, errors)
|
@ -64,7 +64,7 @@ def get_normalized_task(task, candidate, settings):
|
|||||||
return normalized, errors
|
return normalized, errors
|
||||||
|
|
||||||
|
|
||||||
def get_normalized_tasks(candidate, settings):
|
def get_normalized_tasks(candidate, settings, full=False):
|
||||||
normalized = []
|
normalized = []
|
||||||
errors = []
|
errors = []
|
||||||
try:
|
try:
|
||||||
@ -77,9 +77,16 @@ def get_normalized_tasks(candidate, settings):
|
|||||||
# An empty `tags` block causes `None` to be returned if
|
# An empty `tags` block causes `None` to be returned if
|
||||||
# the `or []` is not present - `task.get("tags", [])`
|
# the `or []` is not present - `task.get("tags", [])`
|
||||||
# does not suffice.
|
# does not suffice.
|
||||||
if "skip_ansible_lint" in (task.get("tags") or []):
|
|
||||||
|
# Deprecated.
|
||||||
|
if "skip_ansible_lint" in (task.get("tags") or []) and not full:
|
||||||
# No need to normalize_task if we are skipping it.
|
# No need to normalize_task if we are skipping it.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if "skip_ansible_later" in (task.get("tags") or []) and not full:
|
||||||
|
# No need to normalize_task if we are skipping it.
|
||||||
|
continue
|
||||||
|
|
||||||
normalized.append(
|
normalized.append(
|
||||||
normalize_task(task, candidate.path, settings["ansible"]["custom_modules"])
|
normalize_task(task, candidate.path, settings["ansible"]["custom_modules"])
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user