community.general icon indicating copy to clipboard operation
community.general copied to clipboard

xbps module fails to report install error

Open eoli3n opened this issue 3 years ago • 5 comments

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

  • [X] I agree to follow the Ansible Code of Conduct

eoli3n avatar May 10 '21 08:05 eoli3n

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 avatar May 10 '21 08:05 ansibullbot

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

ansibullbot avatar May 10 '21 08:05 ansibullbot

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 avatar May 13 '21 21:05 the-maldridge

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!

the-maldridge avatar May 14 '21 03:05 the-maldridge

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

ansibullbot avatar Nov 11 '22 01:11 ansibullbot