# Buggy code
def _preprocess_role_spec(self, ds):
    if "role" in ds:
        # Old style: {role: "galaxy.role,version,name", other_vars: "here" }
        role_info = role_spec_parse(ds["role"])
        if isinstance(role_info, dict):
            # Warning: Slight change in behaviour here.  name may be being
            # overloaded.  Previously, name was only a parameter to the role.
            # Now it is both a parameter to the role and the name that
            # ansible-galaxy will install under on the local system.
            if "name" in ds and "name" in role_info:
                del role_info["name"]
            ds.update(role_info)
    else:
        # New style: { src: 'galaxy.role,version,name', other_vars: "here" }
        if (
            "github.com" in ds["src"]
            and "http" in ds["src"]
            and "+" not in ds["src"]
            and not ds["src"].endswith(".tar.gz")
        ):
            ds["src"] = "git+" + ds["src"]

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

        if "name" in ds:
            ds["role"] = ds["name"]
            del ds["name"]
        else:
            ds["role"] = repo_url_to_role_name(ds["src"])

        # set some values to a default value, if none were specified
        ds.setdefault("version", "")
        ds.setdefault("scm", None)

    return ds


# Traceback (NameError)
Unexpected Exception: global name 'scm_archive_role' is not defined
the full traceback was:

Traceback (most recent call last):
File "/Users/guido/ansible/bin/ansible-galaxy", line 79, in <module>
sys.exit(cli.run())
File "/Users/guido/ansible/lib/ansible/cli/galaxy.py", line 136, in run
self.execute()
File "/Users/guido/ansible/lib/ansible/cli/__init__.py", line 97, in execute
fn()
File "/Users/guido/ansible/lib/ansible/cli/galaxy.py", line 369, in execute_install
tmp_file = scm_archive_role(role.scm, role.src, role.version, role.name)
NameError: global name 'scm_archive_role' is not defined

# Fixed code
def _preprocess_role_spec(self, ds):
    if "role" in ds:
        # Old style: {role: "galaxy.role,version,name", other_vars: "here" }
        role_info = RoleRequirement.role_spec_parse(ds["role"])
        if isinstance(role_info, dict):
            # Warning: Slight change in behaviour here.  name may be being
            # overloaded.  Previously, name was only a parameter to the role.
            # Now it is both a parameter to the role and the name that
            # ansible-galaxy will install under on the local system.
            if "name" in ds and "name" in role_info:
                del role_info["name"]
            ds.update(role_info)
    else:
        # New style: { src: 'galaxy.role,version,name', other_vars: "here" }
        if (
            "github.com" in ds["src"]
            and "http" in ds["src"]
            and "+" not in ds["src"]
            and not ds["src"].endswith(".tar.gz")
        ):
            ds["src"] = "git+" + ds["src"]

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

        if "name" in ds:
            ds["role"] = ds["name"]
            del ds["name"]
        else:
            ds["role"] = RoleRequirement.repo_url_to_role_name(ds["src"])

        # set some values to a default value, if none were specified
        ds.setdefault("version", "")
        ds.setdefault("scm", None)

    return ds