Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Stricken1670 opened this issue Mar 14, 2025 · 3 comments
Closed
1 task done

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

Stricken1670 opened this issue Mar 14, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@Stricken1670
Copy link

Stricken1670 commented Mar 14, 2025

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

@Stricken1670 Stricken1670 added the bug Something isn't working label Mar 14, 2025
@Stricken1670
Copy link
Author

See also: puppetlabs/puppet#9520

@silug
Copy link

silug commented Mar 14, 2025

@Stricken1670 See OpenVoxProject/puppet#19 and OpenVoxProject/puppet#20.

@Stricken1670
Copy link
Author

Closing in favor of #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants