Catch additional assertion errors for load_list_of_blocks

pull/13400/head
Matt Martz 9 years ago
parent 53cd802251
commit ce54a59cdc

@ -34,10 +34,7 @@ def load_list_of_blocks(ds, play, parent_block=None, role=None, task_include=Non
# we import here to prevent a circular dependency with imports
from ansible.playbook.block import Block
try:
assert isinstance(ds, (list, type(None)))
except AssertionError:
raise AnsibleParserError("Task list is not a list, invalid format provided: %s" % ds)
block_list = []
if ds:

@ -171,11 +171,17 @@ class Role(Base, Become, Conditional, Taggable):
task_data = self._load_role_yaml('tasks')
if task_data:
try:
self._task_blocks = load_list_of_blocks(task_data, play=self._play, role=self, loader=self._loader)
except:
raise AnsibleParserError("The tasks/main.yml file for role '%s' must contain a list of tasks" % self._role_name , obj=task_data)
handler_data = self._load_role_yaml('handlers')
if handler_data:
try:
self._handler_blocks = load_list_of_blocks(handler_data, play=self._play, role=self, use_handlers=True, loader=self._loader)
except:
raise AnsibleParserError("The handlers/main.yml file for role '%s' must contain a list of tasks" % self._role_name , obj=task_data)
# vars and default vars are regular dictionaries
self._role_vars = self._load_role_yaml('vars')

Loading…
Cancel
Save