##### 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
```

def remove_packages(module, pacman_path, packages):
    data = []
    diff = {
        'before': '',
        'after': '',
    }
    if module.params["force"]:
        module.params["extra_args"] += " --nodeps --nodeps"
    remove_c = 0
    
    for package in packages:
        
        installed, updated, unknown = query_package(module, pacman_path, package)
        if not installed:
            continue
        cmd = "%s --remove --noconfirm --noprogressbar %s %s" % (pacman_path, module.params["extra_args"], package)
        rc, stdout, stderr = module.run_command(cmd, check_rc=False)
        if rc != 0:
            module.fail_json(msg="failed to remove %s" % (package))
        if module._diff:
            d = stdout.split('\n')[2].split(' ')[2:]
            for i, pkg in enumerate(d):
                d[i] = re.sub('-[0-9].*$', '', d[i].split('/')[-1])
                diff['before'] += "%s\n" % pkg
            data.append('\n'.join(d))
        remove_c += 1
    if remove_c > 0:
        module.exit_json(changed=True, msg="removed %s package(s)" % remove_c, diff=diff)
    module.exit_json(changed=False, msg="package(s) already absent")
def install_packages(module, pacman_path, state, packages, package_files):