summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Albertson <lance@osuosl.org>2021-04-07 12:17:24 -0700
committerLance Albertson <lance@osuosl.org>2021-04-07 16:33:17 -0700
commit33e9a20cb27089191ce26ae12a4b7408840887ed (patch)
tree15298ce60130cec461955efe751238612ea41670
parentebff3e7aa22d12d645db3a311a8200c2ed611d18 (diff)
downloadchef-33e9a20cb27089191ce26ae12a4b7408840887ed.tar.gz
Fall back to lsb data if os_release data is missing
The redhat-lsb-core isn't install as a base package which includes lsb_release so let's use os_release data first (if it's available) [1] and fall back to lsb data. [1] https://github.com/chef/ohai/pull/1645 Signed-off-by: Lance Albertson <lance@osuosl.org>
-rw-r--r--chef-utils/lib/chef-utils/dsl/platform.rb6
-rw-r--r--chef-utils/spec/unit/dsl/platform_spec.rb11
2 files changed, 14 insertions, 3 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/platform.rb b/chef-utils/lib/chef-utils/dsl/platform.rb
index 8dd852af3e..9dd336b690 100644
--- a/chef-utils/lib/chef-utils/dsl/platform.rb
+++ b/chef-utils/lib/chef-utils/dsl/platform.rb
@@ -131,7 +131,11 @@ module ChefUtils
# @return [Boolean]
#
def centos_stream_platform?(node = __getnode)
- node.dig("lsb", "id") == "CentOSStream"
+ if node["os_release"]
+ node.dig("os_release", "name") == "CentOS Stream"
+ else
+ node.dig("lsb", "id") == "CentOSStream"
+ end
end
# Determine if the current node is Oracle Linux.
diff --git a/chef-utils/spec/unit/dsl/platform_spec.rb b/chef-utils/spec/unit/dsl/platform_spec.rb
index 997d1d5f43..8ebdcbae8f 100644
--- a/chef-utils/spec/unit/dsl/platform_spec.rb
+++ b/chef-utils/spec/unit/dsl/platform_spec.rb
@@ -145,9 +145,16 @@ RSpec.describe ChefUtils::DSL::Platform do
platform_reports_true_for(:centos?, :centos_platform?)
end
- context "on centos stream" do
+ context "on centos stream w/o os_release" do
let(:options) { { platform: "centos" } }
- let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "lsb" => { "id" => "CentOSStream" } } }
+ let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "lsb" => { "id" => "CentOSStream" }, "os_release" => nil } }
+
+ platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
+ end
+
+ context "on centos stream w/ os_release" do
+ let(:options) { { platform: "centos" } }
+ let(:node) { { "platform" => "centos", "platform_version" => "8", "platform_family" => "rhel", "os" => "linux", "os_release" => { "name" => "CentOS Stream" } } }
platform_reports_true_for(:centos?, :centos_platform?, :centos_stream_platform?)
end