ansible-collections / community.general

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

[pacman] Force specific package upgrade to bypass pacman's IgnorePkg list #5006

Open Rumb0 opened 2 years ago

Rumb0 commented 2 years ago

Summary

Proposal: use force: true to install/upgrade specific packages also listed in pacman's IgnorePkg option.

I use plugin community.general.pacman to install/upgrade packages and pacman's IgnorePkg option to hold certain subset of packages while upgrading the whole system (basically: pacman -Syu). And then upgrade those packages in their respective roles. Plugin behaviour has changed [commit] and now it's impossible to upgrade packages listed in IgnorePkg through pacman plugin.

Issue Type

Feature Idea

Component Name

pacman

Additional Information

This task should be able to upgrade redis package to the latest available version even if we have IgnorePkg = redis option in /etc/pacman.conf:

- name: Install latest redis package
  pacman:
    name: redis
    state: latest
    force: true
  notify: restart redis-server

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

felixfontein commented 2 years ago

CC @jraby

jraby commented 2 years ago

The proposal definitely makes sense. @Rumb0 have you looked at what the current module does wrong/different and why it doesn't work?

Rumb0 commented 2 years ago

Yes, current module excludes packages marked by pacman as ignored from upgradable_pkgs when it creates an inventory. Therefore, when we ask for upgrade of certain packages, they are filtered out by this expression:

            if (
                p.name not in self.inventory["installed_pkgs"]
                or self.target_state == "latest"
                and p.name in self.inventory["upgradable_pkgs"]
            ):
                pkgs_to_install.append(p)

This can be solved by creating a list of upgradable_ignored_pkgs and merging this list with upgradable_pkgs if force: true is used.

Rumb0 commented 2 years ago

can submit PR on this

Dan-Sun commented 2 years ago

Is there any news on this?

@Rumb0

I use plugin community.general.pacman to install/upgrade packages and pacman's IgnorePkg option to hold certain subset of packages

But it is not possible with this module to actually add packages to the ignore list, right?

Rumb0 commented 2 years ago

@Dan-Sun

Is there any news on this?

Nope. To be clear, I doubt that we even need to use force: true when upgrading specific packages listed in IgnorePkg. Even pacman client has default option Yes, when you try to do so.

[root@localhost]:~> pacman -S ruby
:: ruby is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] 

But it is not possible with this module to actually add packages to the ignore list, right?

It's not possible with this module, as it requires to modify pacman.conf.

Dan-Sun commented 2 years ago

extra_args or upgrade_extra_args for noconfirm should work as well, right? I haven't tried it yet. But like this:

- name: Install latest redis package
  pacman:
    name: redis
    state: latest
    upgrade_extra_args: --noconfirm
  notify: restart redis-server
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