summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-11-26 20:02:41 -0800
committerTim Smith <tsmith@chef.io>2018-11-26 20:02:41 -0800
commit643599c626c2c5d1f3b89950d262a647a0581756 (patch)
treeef71a5c825216d98db60bf2a2dee5ea18112898a
parent8b02ee16fd3c7f28ffcbc236132467793c6b6a40 (diff)
downloadohai-643599c626c2c5d1f3b89950d262a647a0581756.tar.gz
Make sure centos continues to correctly parse out versions
CentOS doesn't do the right thing with the os-release file. They treat it differently than redhat and every other distro I've seen. We need to work around that. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/linux/platform.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index a38fcfc6..343238c5 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -47,7 +47,10 @@ Ohai.plugin(:Platform) do
# CentOS release 6.7 (Final)
# Red Hat Enterprise Linux Server release 7.5 (Maipo)
#
- # @deprecated
+ # @param contents [String] the contents of /etc/redhat-release
+ #
+ # @returns [String] the version string
+ #
def get_redhatish_version(contents)
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
end
@@ -289,7 +292,12 @@ Ohai.plugin(:Platform) do
# where we've traditionally used the kernel as the version
# @return String the OS version
def determine_os_version
- os_release_info["VERSION_ID"] || `/bin/uname -r`.strip
+ # centos only includes the major version in os-release for some reason
+ if os_release_info['ID'] == 'centos'
+ get_redhatish_version
+ else
+ os_release_info["VERSION_ID"] || `/bin/uname -r`.strip
+ end
end
collect_data(:linux) do