ansible-collections / community.general

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

Zypper module do not remove a packages which contains wildcard #3138

Open Alexhha opened 2 years ago

Alexhha commented 2 years ago

Summary

Can't remove packages if name contains wildcard

  - name: Uninstall PostgreSQL
    become: yes
    zypper:
      name: ["postgresql*"]
      state: absent

It works with apt/yum modules, but doesn't work with zypper

Issue Type

Bug Report

Component Name

zypper

Ansible Version

$ ansible --version
ansible 2.9.22
  config file = /Users/alex/work/bitbucket/master/ansible/ansible.cfg
  configured module search path = ['/Users/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ansible
  executable location = /Library/Frameworks/Python.framework/Versions/3.8/bin/ansible
  python version = 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) [Clang 6.0 (clang-600.0.57)]

Configuration

$ ansible-config dump --only-changed

OS / Environment

SLES12 SP5

Steps to Reproduce

- name: DEBUG
  hosts: all
  gather_facts: no

  tasks:
  - name: Uninstall PostgreSQL
    become: yes
    zypper:
      name: ["postgresql*"]
      state: absent

Expected Results

All postgresql packages should be removed

Actual Results

A packages were not removed

$ rpm -qa | grep postgresql
postgresql12-server-12.3-1PGDG.sles12.x86_64
postgresql12-12.3-1PGDG.sles12.x86_64
postgresql12-libs-12.3-1PGDG.sles12.x86_64

zypper itself supports wildcard

$ zypper rm postgresql*
zypper rm postgresql*
Loading repository data...
Warning: No repositories defined. Operating only with the installed resolvables. Nothing can be installed.
Reading installed packages...
Resolving package dependencies...

The following 3 packages are going to be REMOVED:
  postgresql12 postgresql12-libs postgresql12-server

3 packages to remove.
After the operation, 69.1 MiB will be freed.
Continue? [y/n/...? shows all options] (y):

Code of Conduct

ansibullbot commented 2 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 2 years ago

cc @AnderEnder @alxgu @andytom @commel @dcermak @evrardjp @lrupp @sealor @toabctl click here for bot help

felixfontein commented 2 years ago

Does the module document that it supports wildcards somewhere? If not, this isn't a bug, but a feature request. In the documentation, I only found the special value * for state=latest.

Alexhha commented 2 years ago

It doesn't, but the same for apt/yum modules. They are not document * support, but they do support

felixfontein commented 2 years ago

The modules mostly pass the user input on to the package manager, which is why wildcards seem to work in some cases. If the modules don't explicitly support wildcards, things like idempotency and presence checking will fail, which is probably what you are experiencing here.

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