Chef Server and problem with YUM

Hi All,
Possibly someone will be able to help. The thing is that when we run a cookbook that should install Java 8 as openJDK package it works fine on CentOS up to version CentOS 7.9. When we try to run it on Rocky Linux 9.3 (which uses DNF instead of YUM) it fails with the following error:

Running handlers:
[2024-02-07T10:23:50+00:00] ERROR: Running exception handlers
Running handlers complete
[2024-02-07T10:23:50+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2024-02-07T10:23:50+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2024-02-07T10:23:50+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2024-02-07T10:23:50+00:00] ERROR: package[java-1.8.0-openjdk] (java::openjdk line 54) had an error: NoMethodError: undefined method `version' for nil:NilClass
[2024-02-07T10:23:51+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Does anyone can advise what the problem is and how to fix it?

Thanks in advance.

What happens when you manually install dnf install java-1.8.0-openjdk on that box?

The error looks like the package cannot be found (version is nil).

Best

Christopher

Hi,
That's weird, as when I try to install it manually it works, but not via Chef.
When I run the same recipe on CentOS 7.9 it works fine - the same recipe. I think this might be caused by YUM that has a symlink to DNF. Maybe DNF misreads it?

Slawek

Different commands for Yum and DNF

~WRD0000.jpg

image001.png

Why not use the package resource? Then it will do the right thing no matter the version.

That is an excellent idea, in fact we do that on a lot of systems.

Just use the rpm commands directly

~WRD0000.jpg

image001.png

| jimbray
February 7 |

  • | - |

That is an excellent idea, in fact we do that on a lot of systems.

Just use the rpm commands directly

RPM commands need to know where the file is, directly, for installation. It doesn't support handling the dependencies or multiple upstream repositories or conflicts directly.

The "yum", "dnf", and "package" modules for ansible, even if they all wind up using the "dnf" command on recent RHEL compatible Linux.

Apologies for late response.
RPM commands may help to install packages directly, however we have some libraries that have hardcoded yum commands which we can't avoid using as these are in a binary files. We can't do reverse engineering of course.

Any other ideas guys?