Bug #2060

Inconsistent output in operatingsystemrelease between RedHat and CentOS

Added by Oliver Hookins over 1 year ago. Updated about 1 year ago.

Status:Closed Start:03/09/2009
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:library
Target version:1.6.0
Keywords: Branch:
Votes: 0

Description

[root@centos ~]# cat /etc/redhat-release 
CentOS release 5.2 (Final)
[root@centos ~]# facter operatingsystemrelease
5.2

[root@rhel ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
[root@rhel ~]# facter operatingsystemrelease
5

It doesn’t make sense that one reports the point release version and the other doesn’t, especially given they are more or less equivalent platforms. If I had my way I would prefer without the point release.

You could patch it like this:

--- operatingsystemrelease.rb.orig  2009-03-09 15:16:22.000000000 +1100
+++ operatingsystemrelease.rb   2009-03-09 15:16:46.000000000 +1100
@@ -55,7 +55,7 @@
     setcode do
         centos_release = Facter::Util::Resolution.exec("sed -r -e 's/CentOS release //' -e 's/ \((Branch|Final)\)//' /etc/redhat-release")
         if centos_release =~ /5/
-            release = Facter::Util::Resolution.exec('rpm -q --qf \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1,2')
+            release = Facter::Util::Resolution.exec('rpm -q --qf \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1')
         else
             release = centos_release
         end

Related issues

duplicated by Facter - Bug #2070: $lsbdistrelease different between EL4 and EL5 Duplicate 03/12/2009

History

Updated by Oliver Hookins over 1 year ago

Actually, scratch that. This is much simpler:

--- operatingsystemrelease.rb.orig  2009-03-09 15:21:18.000000000 +1100
+++ operatingsystemrelease.rb   2009-03-09 15:22:01.000000000 +1100
@@ -13,7 +13,7 @@
 end
 
 Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => %w{RedHat}
+    confine :operatingsystem => %w{RedHat CentOS}
     setcode do
         File::open("/etc/redhat-release", "r") do |f|
             line = f.readline.chomp
@@ -51,18 +51,6 @@
 end
 
 Facter.add(:operatingsystemrelease) do
-    confine :operatingsystem => %w{CentOS}
-    setcode do
-        centos_release = Facter::Util::Resolution.exec("sed -r -e 's/CentOS release //' -e 's/ \((Branch|Final)\)//' /etc/redhat-release")
-        if centos_release =~ /5/
-            release = Facter::Util::Resolution.exec('rpm -q --qf \'%{VERSION}.%{RELEASE}\' centos-release | cut -d. -f1,2')
-        else
-            release = centos_release
-        end
-    end
-end
-
-Facter.add(:operatingsystemrelease) do
     confine :operatingsystem => %w{Debian}
     setcode do
         release = Facter::Util::Resolution.exec('cat /etc/debian_version')

Updated by James Turnbull over 1 year ago

  • Category set to library
  • Status changed from Unreviewed to Needs design decision
  • Assignee set to Puppet Community
  • Target version set to 1.6.0

This needs discussion – see the puppet-dev list thread.

Updated by Luke Kanies over 1 year ago

  • Status changed from Needs design decision to Accepted

I think the consensus was that this was the right thing to do, even though it would cause some breakage.

Updated by James Turnbull over 1 year ago

  • Status changed from Accepted to Ready for Testing
  • Target version changed from 1.6.0 to 1.5.5

See patch submitted to -dev list.

Updated by Luke Kanies over 1 year ago

  • Target version changed from 1.5.5 to 1.6.0

I don’t think this should be in 1.5.5; people don’t expect backward compatibility issues in X.Y.Z releases.

Please delay until 1.6.

Updated by James Turnbull about 1 year ago

  • Assignee deleted (Puppet Community)

Updated by Paul Nasrat about 1 year ago

Todd’s patch pushed to tickets/master/2060 on my github.

Updated by Paul Nasrat about 1 year ago

  • Status changed from Ready for Testing to Ready for Checkin

Updated by Paul Nasrat about 1 year ago

  • Status changed from Ready for Checkin to Closed

Also available in: Atom PDF