# Buggy code
def get_block_list(self, play=None, variable_manager=None, loader=None):
    # only need play passed in when dynamic
    if play is None:
        myplay = self._parent._play
    else:
        myplay = play

    ri = RoleInclude.load(
        self._role_name, play=myplay, variable_manager=variable_manager, loader=loader
    )
    ri.vars.update(self.vars)

    # build role
    actual_role = Role.load(
        ri, myplay, parent_role=self._parent_role, from_files=self._from_files
    )
    actual_role._metadata.allow_duplicates = self.allow_duplicates

    # compile role with parent roles as dependencies to ensure they inherit
    # variables
    if not self._parent_role:
        dep_chain = []
    else:
        dep_chain = list(self._parent_role._parents)
        dep_chain.append(self._parent_role)

    blocks = actual_role.compile(play=myplay, dep_chain=dep_chain)
    for b in blocks:
        b._parent = self

    # updated available handlers in play
    handlers = actual_role.get_handler_blocks(play=myplay)
    myplay.handlers = myplay.handlers + handlers
    return blocks, handlers


# Traceback (AttributeError)
TASK [foo : include] **************************************************************************************************************************************************************************
task path: /tmp/demo/roles/foo/tasks/main.yml:2
ERROR! Unexpected Exception, this is probably a bug: 'NoneType' object has no attribute 'rfind'
the full traceback was:

Traceback (most recent call last):
File "/home/spredzy/Projects/github.com/Spredzy/ansible/bin/ansible-playbook", line 106, in <module>
exit_code = cli.run()
File "/home/spredzy/Projects/github.com/Spredzy/ansible/lib/ansible/cli/playbook.py", line 130, in run
results = pbex.run()
File "/home/spredzy/Projects/github.com/Spredzy/ansible/lib/ansible/executor/playbook_executor.py", line 153, in run
result = self._tqm.run(play=play)
File "/home/spredzy/Projects/github.com/Spredzy/ansible/lib/ansible/executor/task_queue_manager.py", line 285, in run
play_return = strategy.run(iterator, play_context)
File "/home/spredzy/Projects/github.com/Spredzy/ansible/lib/ansible/plugins/strategy/linear.py", line 331, in run
variable_manager=self._variable_manager
File "/home/spredzy/Projects/github.com/Spredzy/ansible/lib/ansible/playbook/included_file.py", line 104, in process_include_results
parent_include_dir = os.path.dirname(templar.template(parent_include.args.get('_raw_params')))
File "/usr/lib64/python2.7/posixpath.py", line 122, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

# Fixed code
def get_block_list(self, play=None, variable_manager=None, loader=None):
    # only need play passed in when dynamic
    if play is None:
        myplay = self._parent._play
    else:
        myplay = play

    ri = RoleInclude.load(
        self._role_name, play=myplay, variable_manager=variable_manager, loader=loader
    )
    ri.vars.update(self.vars)

    # build role
    actual_role = Role.load(
        ri, myplay, parent_role=self._parent_role, from_files=self._from_files
    )
    actual_role._metadata.allow_duplicates = self.allow_duplicates

    # save this for later use
    self._role_path = actual_role._role_path

    # compile role with parent roles as dependencies to ensure they inherit
    # variables
    if not self._parent_role:
        dep_chain = []
    else:
        dep_chain = list(self._parent_role._parents)
        dep_chain.append(self._parent_role)

    blocks = actual_role.compile(play=myplay, dep_chain=dep_chain)
    for b in blocks:
        b._parent = self

    # updated available handlers in play
    handlers = actual_role.get_handler_blocks(play=myplay)
    myplay.handlers = myplay.handlers + handlers
    return blocks, handlers