FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 787b1bc3 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Add rule to ensure template destinations do not end .j2

parent 338377e3
No related branches found
No related tags found
No related merge requests found
import os
import re
from ansiblelint import AnsibleLintRule
marker = re.compile('{{\s*ansible_managed\s*|\s*chem_manage\s*}}')
class TemplateDestsLackJinjaSuffix(AnsibleLintRule):
id = 'CHEM0006'
short_desc = 'Template desinations should not end .j2'
description = 'Destinations of templated files ending .j2 are usually ' \
'indicative of a copy/paste error from the src line'
tags = ['safety']
def matchtask(self,taskfile,task):
results = []
if task['action']['__ansible_module__'] == 'template':
if task['action']['dest'].endswith('.j2'):
results.append(task['action']['dest'])
if results:
return "Template destinations {} end with .j2".format(' '.join(results))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment