puppetlabs / puppet

Server automation framework and application
https://puppet.com/open-source/#osp
Apache License 2.0
7.46k stars 2.19k forks source link

puppet agent not working with dnf5 #9506

Open xxjack12xx opened 1 month ago

xxjack12xx commented 1 month ago

puppet agent does not support dnf5 which is the current package manager in Fedora 41.

When having puppet install a package, the following error occurs: Package[rsync-daemon]/ensure: change from 'purged' to 'present' failed: Execution of '/bin/dnf -d 0 -e 1 -y install rsync-daemon' returned 2: Unknown argument "-d" for command "dnf5". Add "--help" for more information about the arguments. (corrective)

MasinAD commented 3 weeks ago

I stumbled upon this, too. My workaround at the moment is

ln -s /usr/local/bin/dnf /usr/bin/dnf4

But that's not something I want to apply to a whole fleet of managed machines, especially as dnf5 and dnf4 seem to be using different databases to keep track of packages, and dnf5 has other improvements we are missing out (smaller downloads, faster operation).

AriaXLi commented 3 weeks ago

Hi @xxjack12xx, thank you for reporting this issue! While we agree this is likely a bug, we do not anticipate addressing this any time soon due to other issues demanding precedence. However, this is on the team's radar.

vchepkov commented 3 weeks ago

FYI, -d and -e switches were deprecated in dnf4 already

bbkz commented 2 weeks ago

The switches can be found in ruby/vendor_ruby/puppet/provider/package/dnfmodule.rb . Currently it is blocking the use of the puppet agent on Fedora 41 for me as i have many modules using packages.

Stricken1670 commented 2 weeks ago

Here is some example code that triggers the problem:

  package{'gnome-tweaks':
    ensure   => present,
  }

And the error:

Error: Execution of '/usr/bin/dnf -d 0 -e 1 -y install gnome-tweaks' returned 2: Unknown argument "-d" for command "dnf5". Add "--help" for more information about the arguments.
Error: /Stage[main]/Desktop_fedora::Gnome/Package[gnome-tweaks]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/dnf -d 0 -e 1 -y install gnome-tweaks' returned 2: Unknown argument "-d" for command "dnf5". Add "--help" for more information about the arguments.
Stricken1670 commented 2 weeks ago

The switches can be found in ruby/vendor_ruby/puppet/provider/package/dnfmodule.rb . Currently it is blocking the use of the puppet agent on Fedora 41 for me as i have many modules using packages.

This is for the dnf module command, so although this code will absolutely have the same problem and will also need fixing, it is not the cause for our problems.

Stricken1670 commented 2 weeks ago

Found the real culprit: puppet/lib/ruby/vendor_ruby/puppet/provider/package/yum.rb

    # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;                                                                       
    # ensure we capture output to check for errors.                                                                                                                           
    no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : []
    command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact
    output = execute(command)