mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-28 15:50:35 +00:00
22 lines
649 B
Python
22 lines
649 B
Python
import os
|
|
|
|
from ansiblelater.rule import RuleBase
|
|
|
|
|
|
class CheckYamlFile(RuleBase):
|
|
rid = "YML106"
|
|
description = "Roles file should be in yaml format"
|
|
helptext = "file does not have a .yml extension"
|
|
types = ["playbook", "task", "handler"]
|
|
|
|
def check(self, candidate, settings):
|
|
errors = []
|
|
extensions = [".yml", ".yaml"]
|
|
|
|
if os.path.isfile(candidate.path) and os.path.splitext(candidate.path)[1] in extensions:
|
|
content, errors = self.get_raw_yaml(candidate, settings)
|
|
else:
|
|
errors.append(self.Error(None, self.helptext))
|
|
|
|
return self.Result(candidate.path, errors)
|