# Buggy code
def role_yaml_parse(role):
    if isinstance(role, string_types):
        name = None
        scm = None
        src = None
        version = None
        if "," in role:
            if role.count(",") == 1:
                (src, version) = role.strip().split(",", 1)
            elif role.count(",") == 2:
                (src, version, name) = role.strip().split(",", 2)
            else:
                raise AnsibleError(
                    "Invalid role line (%s). Proper format is 'role_name[,version[,name]]'"
                    % role
                )
        else:
            src = role

        if name is None:
            name = RoleRequirement.repo_url_to_role_name(src)
        if "+" in src:
            (scm, src) = src.split("+", 1)

        return dict(name=name, src=src, scm=scm, version=version)

    if "role" in role:
        name = role["role"]
        if "," in name:
            raise AnsibleError("Invalid old style role requirement: %s" % name)
        else:
            del role["role"]
            role["name"] = name
    else:
        role = role.copy()

        if "src" in role:
            # New style: { src: 'galaxy.role,version,name', other_vars: "here" }
            if (
                "github.com" in role["src"]
                and "http" in role["src"]
                and "+" not in role["src"]
                and not role["src"].endswith(".tar.gz")
            ):
                role["src"] = "git+" + role["src"]

            if "+" in role["src"]:
                (scm, src) = role["src"].split("+")
                role["scm"] = scm
                role["src"] = src

            if "name" not in role:
                role["name"] = RoleRequirement.repo_url_to_role_name(role["src"])

        if "version" not in role:
            role["version"] = ""

        if "scm" not in role:
            role["scm"] = None

    for key in list(role.keys()):
        if key not in VALID_SPEC_KEYS:
            role.pop(key)

    return role


# Traceback (ValueError)
[root@cockpit vagrant]# ansible-galaxy install -vvv -r req.yml
ansible-galaxy 2.6.3
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.6/site-packages/ansible
executable location = /usr/bin/ansible-galaxy
python version = 2.6.6 (r266:84292, Aug  9 2016, 06:11:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
Using /etc/ansible/ansible.cfg as config file
Opened /root/.ansible_galaxy
ERROR! Unexpected Exception, this is probably a bug: too many values to unpack
the full traceback was:

Traceback (most recent call last):
File "/usr/bin/ansible-galaxy", line 118, in <module>
exit_code = cli.run()
File "/usr/lib/python2.6/site-packages/ansible/cli/galaxy.py", line 152, in run
self.execute()
File "/usr/lib/python2.6/site-packages/ansible/cli/__init__.py", line 155, in execute
fn()
File "/usr/lib/python2.6/site-packages/ansible/cli/galaxy.py", line 335, in execute_install
role = RoleRequirement.role_yaml_parse(role)
File "/usr/lib/python2.6/site-packages/ansible/playbook/role/requirement.py", line 168, in role_yaml_parse
(scm, src) = role["src"].split('+')
ValueError: too many values to unpack

# Fixed code
def role_yaml_parse(role):
    if isinstance(role, string_types):
        name = None
        scm = None
        src = None
        version = None
        if "," in role:
            if role.count(",") == 1:
                (src, version) = role.strip().split(",", 1)
            elif role.count(",") == 2:
                (src, version, name) = role.strip().split(",", 2)
            else:
                raise AnsibleError(
                    "Invalid role line (%s). Proper format is 'role_name[,version[,name]]'"
                    % role
                )
        else:
            src = role

        if name is None:
            name = RoleRequirement.repo_url_to_role_name(src)
        if "+" in src:
            (scm, src) = src.split("+", 1)

        return dict(name=name, src=src, scm=scm, version=version)

    if "role" in role:
        name = role["role"]
        if "," in name:
            raise AnsibleError("Invalid old style role requirement: %s" % name)
        else:
            del role["role"]
            role["name"] = name
    else:
        role = role.copy()

        if "src" in role:
            # New style: { src: 'galaxy.role,version,name', other_vars: "here" }
            if (
                "github.com" in role["src"]
                and "http" in role["src"]
                and "+" not in role["src"]
                and not role["src"].endswith(".tar.gz")
            ):
                role["src"] = "git+" + role["src"]

            if "+" in role["src"]:
                role["scm"], dummy, role["src"] = role["src"].partition("+")

            if "name" not in role:
                role["name"] = RoleRequirement.repo_url_to_role_name(role["src"])

        if "version" not in role:
            role["version"] = ""

        if "scm" not in role:
            role["scm"] = None

    for key in list(role.keys()):
        if key not in VALID_SPEC_KEYS:
            role.pop(key)

    return role