##### SUMMARY
When using Ansible devel (`pip install git+https://github.com/ansible/ansible.git@devel`) to install software using `package` (likely passed to `pacman` module) and looping over a list of packages, an error is display

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
package
pacman

##### ANSIBLE VERSION
```
ansible 2.10.0.dev0
```

##### CONFIGURATION
```paste below
(empty)
```

##### OS / ENVIRONMENT
controler: ubuntu (on travis)
managed node: Archlinux in a container

##### STEPS TO REPRODUCE
Have a look at [the build](https://travis-ci.org/robertdebock/ansible-role-at/jobs/592714211#L834) and [the code](- name: install bootstrap_facts_packages)

##### EXPECTED RESULTS
No errors.

##### ACTUAL RESULTS
```paste below
835  An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: list index out of range
836    failed: [at-archlinux] (item=python3) => changed=false 
837      ansible_loop_var: item
838      item: python3
839      module_stderr: |-
840        Traceback (most recent call last):
841          File "/root/.ansible/tmp/ansible-tmp-1570043024.2295542-61858662337132/AnsiballZ_pacman.py", line 102, in <module>
842            _ansiballz_main()
843          File "/root/.ansible/tmp/ansible-tmp-1570043024.2295542-61858662337132/AnsiballZ_pacman.py", line 94, in _ansiballz_main
844            invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
845          File "/root/.ansible/tmp/ansible-tmp-1570043024.2295542-61858662337132/AnsiballZ_pacman.py", line 40, in invoke_module
846            runpy.run_module(mod_name='ansible.modules.packaging.os.pacman', init_globals=None, run_name='__main__', alter_sys=False)
847          File "/usr/lib/python3.7/runpy.py", line 208, in run_module
848            return _run_code(code, {}, init_globals, run_name, mod_spec)
849          File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
850            exec(code, run_globals)
851          File "/tmp/ansible_pacman_payload_0g8c68rr/ansible_pacman_payload.zip/ansible/modules/packaging/os/pacman.py", line 500, in <module>
852          File "/tmp/ansible_pacman_payload_0g8c68rr/ansible_pacman_payload.zip/ansible/modules/packaging/os/pacman.py", line 492, in main
853          File "/tmp/ansible_pacman_payload_0g8c68rr/ansible_pacman_payload.zip/ansible/modules/packaging/os/pacman.py", line 341, in install_packages
854        IndexError: list index out of range
855      module_stdout: ''
856      msg: |-
857        MODULE FAILURE
858        See stdout/stderr for the exact error
859      rc: 1
```

would_be_changed = []
    diff = {
        'before': '',
        'after': '',
        'before_header': '',
        'after_header': ''
    }
    for package in packages:
        installed, updated, unknown = query_package(module, pacman_path, package)
        if ((state in ["present", "latest"] and not installed) or
                (state == "absent" and installed) or
                (state == "latest" and not updated)):
            would_be_changed.append(package)
    if would_be_changed:
        if state == "absent":
            state = "removed"
        if module._diff and (state == 'removed'):
            diff['before_header'] = 'removed'
            diff['before'] = '\n'.join(would_be_changed) + '\n'
        elif module._diff and ((state == 'present') or (state == 'latest')):
            diff['after_header'] = 'installed'
            diff['after'] = '\n'.join(would_be_changed) + '\n'
        module.exit_json(changed=True, msg="%s package(s) would be %s" % (
            len(would_be_changed), state), diff=diff)
    else:
        module.exit_json(changed=False, msg="package(s) already %s" % state, diff=diff)
def expand_package_groups(module, pacman_path, pkgs):