ansible-review
ansible-review copied to clipboard
playbooks_should_not_contain_logic function errors when encountering empty playbook
Firstly, many thanks for this great tool.
I'm running ansible-review using the supplied example/standards.py against a role which contains some stub yml files which contain no tasks (yet).
When ansible-review hits one of these files using the supplied example/standards.py, it errors out when applying the 'playbooks_should_not_contain_logic' standard, as follows:
Traceback (most recent call last):
File "/usr/local/bin/ansible-review", line 87, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/bin/ansible-review", line 80, in main
errors = errors + candidate.review(options, lines)
File "/usr/local/lib/python2.7/dist-packages/ansiblereview/__init__.py", line 68, in review
return utils.review(self, settings, lines)
File "/usr/local/lib/python2.7/dist-packages/ansiblereview/utils/__init__.py", line 107, in review
result = standard.check(candidate, settings)
File "/home/anth/dev/ac/anthcourtney.cis-amazon-linux/tests/ansible-review/standards.py", line 104, in playbook_contains_logic
for play in plays:
TypeError: 'NoneType' object is not iterable
I can work around this by adding a `if plays is not None:`` conditional to the function, however would be interested in your perspective on how to best address this.
That probably is the best fix unless you are willing to always add an empty play to your stub playbook
-
is the most minimal playbook that should currently work (a single empty play, effectively)
Thanks, that's a good suggestion.