ansible-collections / community.general

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

pacman latest fails if there is a dependency #4079

Open jamincollins opened 2 years ago

jamincollins commented 2 years ago

Summary

If you execute the pacman packager with latest but reference a package with a dependency you can wind up with something like the following output:

{"changed": false, "msg": "package(s) already installed. But could not ensure 'latest' state for ['libvirt', 'libvirt-storage-rbd'] package(s) as remote version could not be fetched."}

Issue Type

Bug Report

Component Name

pacman

Ansible Version

$ ansible --version
ansible [core 2.12.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/jamin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.10/site-packages/ansible
  ansible collection location = /home/jamin/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0]
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /usr/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 4.3.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

Arch Linux

Steps to Reproduce

Have an older version of libvirt and libvirt-storage-rbd installed on the host:


---
- hosts: ceph
  tasks:
  - name: Update list of known packages
    community.general.pacman:
      update_cache: yes

  - name: Remove conflicting packages
    #ansible.builtin.package:
    community.general.pacman:
      name:
        - qemu
      state: absent

  - name: Ensure ceph related packages are installed
    #ansible.builtin.package:
    community.general.pacman:
      name:
        - ceph
        - qemu-headless
        - qemu-block-rbd
        - libvirt
        - libvirt-storage-rbd
      state: latest

Expected Results

That a libvirt and libvirt-storage-rbd upgrade be performed/detected if there is a newer version.

Actual Results


ok: [skald-2] => {"changed": false, "msg": "package(s) already installed. But could not ensure 'latest' state for ['libvirt', 'libvirt-storage-rbd'] package(s) as remote version could not be fetched."}

This appears to be caused by the package by package check done here: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/packaging/os/pacman.py#L354-L356

Queried individually, packages with dependencies can result in error:

$ pacman --sync --print-format "%n %v" libvirt; echo $?
error: failed to prepare transaction (could not satisfy dependencies)
:: installing libvirt (1:8.0.0-1) breaks dependency 'libvirt=7.10.0' required by libvirt-storage-rbd
1
$ pacman --sync --print-format "%n %v" libvirt-storage-rbd; echo $?
error: failed to prepare transaction (could not satisfy dependencies)
:: unable to satisfy dependency 'libvirt=8.0.0' required by libvirt-storage-rbd
1

However, queried together, they are not a problem:

$ pacman --sync --print-format "%n %v" libvirt libvirt-storage-rbd; echo $?
libvirt 1:8.0.0-1
libvirt-storage-rbd 1:8.0.0-1
0

Code of Conduct

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

ansibullbot commented 2 years ago

cc @indrajitr @tchernomax click here for bot help

jamincollins commented 2 years ago

What's even worse on this is that without verbose output it claims it worked without issue:

TASK [Ensure ceph related packages are installed] *********************************************************************
ok: [langhus-1]
ok: [langhus-2]
ok: [langhus-3]
ok: [skald-2]
ok: [langhus-4]
ok: [skald-1]
ok: [langhus-5]
felixfontein commented 2 years ago

This might be fixed by #3907, you'd have to check. (That PR is very extensive and nobody had time to review it yet though...)

ansibullbot commented 1 year 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

ansibullbot commented 1 year ago

cc @jraby click here for bot help