summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-04-07 17:02:13 -0700
committerGitHub <noreply@github.com>2021-04-07 17:02:13 -0700
commit0c94bef3cf8a95b844f29171636d348312e5d41e (patch)
tree73fc16e1b0d832032164e5f2521ce9202ed61950
parent1f44afde4de1a2e0e01d1172adb822e4dd762d56 (diff)
parent33e9a20cb27089191ce26ae12a4b7408840887ed (diff)
downloadchef-0c94bef3cf8a95b844f29171636d348312e5d41e.tar.gz
Merge pull request #11296 from ramereth/centos-stream-helper
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--chef-utils/lib/chef-utils/dsl/platform.rb15
-rw-r--r--chef-utils/spec/unit/dsl/platform_spec.rb14
2 files changed, 29 insertions, 0 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/platform.rb b/chef-utils/lib/chef-utils/dsl/platform.rb
index f44cb811bb..9dd336b690 100644
--- a/chef-utils/lib/chef-utils/dsl/platform.rb
+++ b/chef-utils/lib/chef-utils/dsl/platform.rb
@@ -123,6 +123,21 @@ module ChefUtils
# chef-sugar backcompat method
alias_method :centos?, :centos_platform?
+ # Determine if the current node is CentOS Stream.
+ #
+ # @param [Chef::Node] node the node to check
+ # @since 17.0
+ #
+ # @return [Boolean]
+ #
+ def centos_stream_platform?(node = __getnode)
+ 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.
#
# @param [Chef::Node] node the node to check
diff --git a/chef-utils/spec/unit/dsl/platform_spec.rb b/chef-utils/spec/unit/dsl/platform_spec.rb
index 216e15f112..8ebdcbae8f 100644
--- a/chef-utils/spec/unit/dsl/platform_spec.rb
+++ b/chef-utils/spec/unit/dsl/platform_spec.rb
@@ -145,6 +145,20 @@ RSpec.describe ChefUtils::DSL::Platform do
platform_reports_true_for(:centos?, :centos_platform?)
end
+ 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" }, "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
+
context "on clearos" do
let(:options) { { platform: "clearos" } }