# Buggy code
def _load_inventory_file(self, path, loader):
    """
    helper function, which loads the file and gets the
    basename of the file without the extension
    """

    if loader.is_directory(path):
        data = dict()

        try:
            names = loader.list_directory(path)
        except os.error as err:
            raise AnsibleError(
                "This folder cannot be listed: %s: %s." % (path, err.strerror)
            )

        # evaluate files in a stable order rather than whatever
        # order the filesystem lists them.
        names.sort()

        # do not parse hidden files or dirs, e.g. .svn/
        paths = [os.path.join(path, name) for name in names if not name.startswith(".")]
        for p in paths:
            _found, results = self._load_inventory_file(path=p, loader=loader)
            if results is not None:
                data = combine_vars(data, results)

    else:
        file_name, ext = os.path.splitext(path)
        data = None
        if not ext or ext not in C.YAML_FILENAME_EXTENSIONS:
            for test_ext in C.YAML_FILENAME_EXTENSIONS:
                new_path = path + test_ext
                if loader.path_exists(new_path):
                    data = loader.load_from_file(new_path)
                    break
        else:
            if loader.path_exists(path):
                data = loader.load_from_file(path)

    rval = AnsibleInventoryVarsData()
    rval.path = path
    if data is not None:
        rval.update(data)
    return rval


# Traceback (ValueError)
$ ansible-playbook -i testing-windows  windows-workstations.yml  -vvv
Using /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg as config file
ERROR! Unexpected Exception: need more than 1 value to unpack
the full traceback was:

Traceback (most recent call last):
File "/Users/tanner/projects/ansible.git/ansible/bin/ansible-playbook", line 97, in <module>
exit_code = cli.run()
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/cli/playbook.py", line 154, in run
results = pbex.run()
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/executor/playbook_executor.py", line 73, in run
self._inventory.set_playbook_basedir(os.path.dirname(playbook_path))
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 697, in set_playbook_basedir
self.get_group_vars(group)
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 715, in get_group_vars
return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir)
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 776, in _get_hostgroup_vars
self._variable_manager.add_group_vars_file(base_path, self._loader)
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py", line 602, in add_group_vars_file
data = self._load_inventory_file(path, loader)
File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py", line 540, in _load_inventory_file
_found, results = self._load_inventory_file(path=p, loader=loader)
ValueError: need more than 1 value to unpack

# Fixed code
def _load_inventory_file(self, path, loader):
    """
    helper function, which loads the file and gets the
    basename of the file without the extension
    """

    if loader.is_directory(path):
        data = dict()

        try:
            names = loader.list_directory(path)
        except os.error as err:
            raise AnsibleError(
                "This folder cannot be listed: %s: %s." % (path, err.strerror)
            )

        # evaluate files in a stable order rather than whatever
        # order the filesystem lists them.
        names.sort()

        # do not parse hidden files or dirs, e.g. .svn/
        paths = [os.path.join(path, name) for name in names if not name.startswith(".")]
        for p in paths:
            results = self._load_inventory_file(path=p, loader=loader)
            if results is not None:
                data = combine_vars(data, results)

    else:
        file_name, ext = os.path.splitext(path)
        data = None
        if not ext or ext not in C.YAML_FILENAME_EXTENSIONS:
            for test_ext in C.YAML_FILENAME_EXTENSIONS:
                new_path = path + test_ext
                if loader.path_exists(new_path):
                    data = loader.load_from_file(new_path)
                    break
        else:
            if loader.path_exists(path):
                data = loader.load_from_file(path)

    rval = AnsibleInventoryVarsData()
    rval.path = path
    if data is not None:
        rval.update(data)
    return rval