diff --git a/lib/puppet/provider/package/dnf.rb b/lib/puppet/provider/package/dnf.rb index 4f4fb1e4fde..0799e4c8da6 100644 --- a/lib/puppet/provider/package/dnf.rb +++ b/lib/puppet/provider/package/dnf.rb @@ -46,6 +46,14 @@ def self.update_command 'upgrade' end + # dnf5 removed the -d (debuglevel) and -e (errorlevel) flags. + # These were already deprecated in dnf4. + # + # @return [Array] empty array + def self.quiet_flags + [] + end + # The value to pass to DNF as its error output level. # DNF differs from Yum slightly with regards to error outputting. # diff --git a/lib/puppet/provider/package/dnfmodule.rb b/lib/puppet/provider/package/dnfmodule.rb index 8d58d2fdd8f..0f6d5a6f9f5 100644 --- a/lib/puppet/provider/package/dnfmodule.rb +++ b/lib/puppet/provider/package/dnfmodule.rb @@ -35,7 +35,7 @@ def self.prefetch(packages) def self.instances packages = [] - cmd = "#{command(:dnf)} module list -y -d 0 -e #{error_level}" + cmd = ([command(:dnf), 'module', 'list', '-y'] + quiet_flags).join(' ') execute(cmd).each_line do |line| # select only lines with actual packages since DNF clutters the output next unless line =~ /\[[eix]\][, ]/ @@ -90,7 +90,7 @@ def install enable(args) else begin - execute([command(:dnf), 'module', 'install', '-d', '0', '-e', self.class.error_level, '-y', args]) + execute([command(:dnf), 'module', 'install'] + self.class.quiet_flags + ['-y', args]) rescue Puppet::ExecutionFailure => e # module has no default profile and no profile was requested, so just enable the stream # DNF versions prior to 4.2.8 do not need this workaround @@ -117,20 +117,20 @@ def insync?(is) end def enable(args = @resource[:name]) - execute([command(:dnf), 'module', 'enable', '-d', '0', '-e', self.class.error_level, '-y', args]) + execute([command(:dnf), 'module', 'enable'] + self.class.quiet_flags + ['-y', args]) end def uninstall - execute([command(:dnf), 'module', 'remove', '-d', '0', '-e', self.class.error_level, '-y', @resource[:name]]) + execute([command(:dnf), 'module', 'remove'] + self.class.quiet_flags + ['-y', @resource[:name]]) reset # reset module to the default stream end def disable(args = @resource[:name]) - execute([command(:dnf), 'module', 'disable', '-d', '0', '-e', self.class.error_level, '-y', args]) + execute([command(:dnf), 'module', 'disable'] + self.class.quiet_flags + ['-y', args]) end def reset - execute([command(:dnf), 'module', 'reset', '-d', '0', '-e', self.class.error_level, '-y', @resource[:name]]) + execute([command(:dnf), 'module', 'reset'] + self.class.quiet_flags + ['-y', @resource[:name]]) end def flavor diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 15bc372c6b3..ac02716c381 100644 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -186,6 +186,12 @@ def self.error_level '0' end + # Flags to suppress debug and error output from the package manager. + # @return [Array] command-line flags + def self.quiet_flags + ['-d', '0', '-e', error_level] + end + def self.update_command # In yum both `upgrade` and `update` can be used to update packages # `yum upgrade` == `yum --obsoletes update` @@ -243,11 +249,11 @@ def available_versions(package_name, disablerepo, enablerepo, disableexcludes) def install wanted = @resource[:name] - error_level = self.class.error_level + quiet_flags = self.class.quiet_flags 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)] + quiet_flags + ['-y', install_options, :list, wanted].compact) end should = @resource.should(:ensure) @@ -309,8 +315,7 @@ def install # 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 + command = [command(:cmd)] + quiet_flags + ["-y", install_options, operation, wanted].compact output = execute(command) if output.to_s =~ /^No package #{wanted} available\.$/