ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
836 stars 1.53k forks source link

xbps module fails to report install error #2478

Open eoli3n opened 3 years ago

eoli3n commented 3 years ago

Summary

When i install multiple package with xbps module, if one fails to install, the reported package in the error is the wrong package, the last of the list.

xbps:
  name:
    - package1
    - package2
    - package3

If package2 doesn't exist, the package reported in the error is package3. It makes task debugging harder than it should.

A workaround is to use a loop over the package list as

xbps:
  name: '{{item}}'
loop:
  - package1
  - package2
  - package3

Then if package2 doesn't exist, it is well reported in the error.

Issue Type

Bug Report

Component Name

xbps

Ansible Version

$ ansible --version
ansible [core 2.11.0] 
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.4 (default, Apr 20 2021, 15:51:38) [GCC 10.2.0]
  jinja version = 2.11.3
  libyaml = True

Configuration

$ ansible-config dump --only-changed
# blank

OS / Environment

Latest Voidlinux

Steps to Reproduce

Create a task as

---
- name: install desktop packages
  community.general.xbps:
    name:
      - sway # wayland wm and compositor
      - swaybg # background manager for sway
      - non-existent-package
      - xorg-server-xwayland # xorg backend for wayland
      - Waybar # bar for sway
      - mako # notification daemon

Expected Results

TASK [desktop : install desktop packages] **************************************************************************
task path: /home/user/dev/void-config/ansible/roles/desktop/tasks/main.yml:2
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "name": [
                "sway",
                "swaybg",
                "non-existent-package",
                "xorg-server-xwayland",
                "Waybar",
                "mako"
            ],
            "recurse": false,
            "state": "present",
            "update_cache": true,
            "upgrade": false,
            "upgrade_xbps": true
        }
    },
    "msg": "failed to install non-existent-package"
}

Actual Results

TASK [desktop : install desktop packages] **************************************************************************
task path: /home/user/dev/void-config/ansible/roles/desktop/tasks/main.yml:2
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "force": false,
            "name": [
                "sway",
                "swaybg",
                "non-existent-package",
                "xorg-server-xwayland",
                "Waybar",
                "mako"
            ],
            "recurse": false,
            "state": "present",
            "update_cache": true,
            "upgrade": false,
            "upgrade_xbps": true
        }
    },
    "msg": "failed to install mako"
}

Code of Conduct

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @dinoocch @the-maldridge click here for bot help

the-maldridge commented 3 years ago

Hmm, yeah this is a known defect I remember from several years ago. I'll have to dig further into this to figure out a good solution that doesn't have side effects.

the-maldridge commented 3 years ago

Ok, for those playing along at home what fails here is that the failure message takes the value of 'package' which is a loop iteration variable. Having been working in Go for the last several years I had to refresh my memory to understand why this was even still in scope at all and not a more serious error.

Since this actually ignores a whole class of errors I'm going to sync with the XBPS developers and ask what they believe the best rules should be for parsing the actual full error text out of the XBPS output. I checked my notes and discovered that the last time I ran into this was a host that had no disk space remaining. You can imagine my confusion with trying to debug a package installation issue only to later discover the true cause!

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help