'Returns the role name (either the role: or name: field) from
the role definition, or (when the role definition is a simple
string), just that string'

def _load_role_name(self, ds):

    if isinstance(ds, string_types):
        return ds
    role_name = ds.get('role', ds.get('name'))
    if ((not role_name) or (not isinstance(role_name, string_types))):
        raise AnsibleError('role    definitions    must    contain    a    role    name', obj=ds)
    if self._variable_manager:
        all_vars = self._variable_manager.get_vars(play=self._play)
        templar = Templar(loader=self._loader, variables=all_vars)
        if templar._contains_vars(role_name):
            role_name = templar.template(role_name)
    return role_name
