Skip to content

[Bug]: add support for dnf5 in the yum module #18

Closed
@Stricken1670

Description

@Stricken1670

Is this a critical security issue?

  • This is not a security issue.

Describe the Bug

Since fedora 41 legacy options are no longer supported. These options have been deprecated since RHEL7, which is already EOL.

Error: Execution of '/usr/bin/dnf -d 0 -e 1 -y install openvox-agent' returned 2: Unknown argument "-d" for command "dnf5". Add "--help" for more information about the arguments.
Error: /Stage[main]/Puppet::Agent::Install/Package[openvox-agent]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/dnf -d 0 -e 1 -y install openvox-agent' returned 2: Unknown argument "-d" for command "dnf5". Add "--help" for more information about the arguments.

Here is what I had to do to make the yum module work on fedora 41.

--- /root/yum.rb	2025-03-14 16:00:25.914534483 +0100
+++ puppet/lib/ruby/vendor_ruby/puppet/provider/package/yum.rb	2025-02-26 23:21:14.000000000 +0100
@@ -247,7 +247,7 @@
     update_command = self.class.update_command
     # If not allowing virtual packages, do a query to ensure a real package exists
     unless @resource.allow_virtual?
-      execute([command(:cmd), '-q', '-y', install_options, :list, wanted].compact)
+      execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact)
     end
 
     should = @resource.should(:ensure)
@@ -309,8 +309,8 @@
 
     # 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 ? ["-q"] : []
-    command = [command(:cmd)] + no_debug + ["-y", install_options, operation, wanted].compact
+    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)
 
     if output.to_s =~ /^No package #{wanted} available\.$/
root@rehicp3 /opt/puppetlabs #  diff -u puppet/lib/ruby/vendor_ruby/puppet/provider/package/yum.rb ~/yum.rb
--- puppet/lib/ruby/vendor_ruby/puppet/provider/package/yum.rb	2025-02-26 23:21:14.000000000 +0100
+++ /root/yum.rb	2025-03-14 16:00:25.914534483 +0100
@@ -247,7 +247,7 @@
     update_command = self.class.update_command
     # If not allowing virtual packages, do a query to ensure a real package exists
     unless @resource.allow_virtual?
-      execute([command(:cmd), '-d', '0', '-e', error_level, '-y', install_options, :list, wanted].compact)
+      execute([command(:cmd), '-q', '-y', install_options, :list, wanted].compact)
     end
 
     should = @resource.should(:ensure)
@@ -309,8 +309,8 @@
 
     # 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
+    no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-q"] : []
+    command = [command(:cmd)] + no_debug + ["-y", install_options, operation, wanted].compact
     output = execute(command)
 
     if output.to_s =~ /^No package #{wanted} available\.$/

Of course my suggestion is rather blunt and disregards portability. I'd also like to mention the code duplication in the existing version.

Expected Behavior

Install the package

Steps to Reproduce

Run puppet-agent -t

Environment

Version [e.g. openvox-8.13.0]
Platform [e.g. Fedora 41]

Additional Context

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions