voxpupuli / puppet-yum

Puppet module for Yum
https://forge.puppet.com/puppet/yum
MIT License
16 stars 99 forks source link

Package name must be formatted as %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}, not 'String'. #240

Open JCW-USDA opened 2 years ago

JCW-USDA commented 2 years ago

Any insight would be appreciated, thanks.

I have the following code in the manifest -

yum::versionlock { '0:elasticsearch-7.*':  
  ensure => present,
}

I get the following error on a puppet run when calling that line of code:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Package name must be formatted as %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}, not 'String'. See Yum::Versionlock documentation for details.

Using tag v5.3.1 of this module.

sbrowne-godaddy commented 4 months ago

This also occurs on the v7.1.0 tag, on systems where the $::facts['package_provider'] is dnf (rather than yum).

This simple patch has worked for me on EL9 without breaking EL7 operability.

diff --git a/manifests/versionlock.pp b/manifests/versionlock.pp
index 0a6653d..f398dca 100644
--- a/manifests/versionlock.pp
+++ b/manifests/versionlock.pp
@@ -67,7 +67,7 @@ define yum::versionlock (
     default   => '',
   }

-  if $facts['package_provider'] == 'yum' and $version =~ Undef {
+  if $facts['package_provider'] in [ 'yum', 'dnf' ] and $version =~ Undef {
     assert_type(Yum::VersionlockString, $name) |$_expected, $actual | {
       # lint:ignore:140chars
       fail("Package name must be formatted as %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}, not \'${actual}\'. See Yum::Versionlock documentation for details.")
sbrowne-godaddy commented 4 months ago

That being said, on an EL9 box i'm testing on now, the format of the lines has changed from:

[epoch]:[name]-[version].[archive]

to

[name]-[epoch]:[version].[archive]

More testing obviously required. And yes, in man(8) dnf, it shows:

name-[epoch:]version-release.arch
name.arch
name
name-[epoch:]version-release
name-[epoch:]version

As the accepted package naming formats. NEVRA. This is from the yum man(8) page:

name
name.arch
name-ver
name-ver-rel
name-ver-rel.arch
name-epoch:ver-rel.arch
epoch:name-ver-rel.arch

So, ENVRA is a hang-over from yum on EL6 (and earlier?) doing direct comparisons against the rpm database.