Ansible assumes that roles/x/tasks/main.yml is a plain list of tasks, but when the file is in the format:
tasks:
xxx
…
it fails with unexpected exception (AssertionError):
File “/opt/ansible/ansible/lib/ansible/playbook/helpers.py”, line 37, in load_list_of_blocks
assert isinstance(ds, (list, type(None)))
AssertionError
When it expects ds to be an list, it is actually an dict with ‘task’ key.
It involves digging into the Ansible code to know that my main.yml is malformed. I would suggest Ansible point out the syntax, or accept both format of main.yml.
In either case, I would like to send a patch for review.
All of those AssertionError exceptions should be caught, and the proper AnsibleParserError should be raised instead.
The catching of AssertionError should be happening in all locations where load_list_of_blocks, load_list_of_tasks and load_list_of_roles is being used.
I was unable to find any place where the AssertionError is not being caught in current devel.