summaryrefslogtreecommitdiff
path: root/chef-utils/lib/chef-utils
diff options
context:
space:
mode:
Diffstat (limited to 'chef-utils/lib/chef-utils')
-rw-r--r--chef-utils/lib/chef-utils/dsl/cloud.rb132
-rw-r--r--chef-utils/lib/chef-utils/dsl/windows.rb22
-rw-r--r--chef-utils/lib/chef-utils/version.rb2
3 files changed, 155 insertions, 1 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/cloud.rb b/chef-utils/lib/chef-utils/dsl/cloud.rb
new file mode 100644
index 0000000000..6aba9d1b51
--- /dev/null
+++ b/chef-utils/lib/chef-utils/dsl/cloud.rb
@@ -0,0 +1,132 @@
+#
+# Copyright:: Copyright 2018-2020, Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require_relative "../internal"
+
+module ChefUtils
+ module DSL
+ module Cloud
+ include Internal
+
+ # Determine if the current node is "in the cloud".
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def cloud?(node = __getnode)
+ node.key?("cloud")
+ end
+
+ # Return true if the current current node is in EC2
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def ec2?(node = __getnode)
+ node.key?("ec2")
+ end
+
+ # Return true if the current current node is in GCE
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def gce?(node = __getnode)
+ node.key?("gce")
+ end
+
+ # Return true if the current current node is in Rackspace
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def rackspace?(node = __getnode)
+ node.key?("rackspace")
+ end
+
+ # Return true if the current current node is in Eucalyptus
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def eucalyptus?(node = __getnode)
+ node.key?("eucalyptus")
+ end
+ alias_method :euca?, :eucalyptus?
+
+ # Return true if the current current node is in Linode
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def linode?(node = __getnode)
+ node.key?("linode")
+ end
+
+ # Return true if the current current node is in Openstack
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def openstack?(node = __getnode)
+ node.key?("openstack")
+ end
+
+ # Return true if the current current node is in Azure
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [Boolean]
+ #
+ def azure?(node = __getnode)
+ node.key?("azure")
+ end
+
+ # Return true if the current current node is in DigitalOcean
+ #
+ # @param [Chef::Node] node
+ # the node to check
+ #
+ # @return [Boolean]
+ #
+ def digital_ocean?(node = __getnode)
+ node.key?("digital_ocean")
+ end
+ alias_method :digitalocean?, :digital_ocean?
+
+ # Return true if the current current node is in SoftLayer
+ #
+ # @param [Chef::Node] node
+ # the node to check
+ #
+ # @return [Boolean]
+ #
+ def softlayer?(node = __getnode)
+ node.key?("softlayer")
+ end
+
+ extend self
+ end
+ end
+end
diff --git a/chef-utils/lib/chef-utils/dsl/windows.rb b/chef-utils/lib/chef-utils/dsl/windows.rb
index 86d8fb00bc..904e9ef126 100644
--- a/chef-utils/lib/chef-utils/dsl/windows.rb
+++ b/chef-utils/lib/chef-utils/dsl/windows.rb
@@ -20,6 +20,8 @@ require_relative "../internal"
module ChefUtils
module DSL
module Windows
+ require "chef-utils/version_string"
+
include Internal
# Determine if the current node is Windows Server Core.
@@ -52,6 +54,26 @@ module ChefUtils
node["kernel"]["product_type"] == "Server"
end
+ # Determine the current Windows NT version. The NT version often differs from the marketing version, but offers a good way to find desktop and server releases that are based on the same codebase. IE: NT 6.3 is Windows 8.1 and Windows 2012 R2.
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [ChefUtils::VersionString]
+ #
+ def windows_nt_version(node = __getnode)
+ ChefUtils::VersionString.new(node["os_version"])
+ end
+
+ # Determine the installed version of PowerShell
+ #
+ # @param [Chef::Node] node
+ #
+ # @return [ChefUtils::VersionString]
+ #
+ def powershell_version(node = __getnode)
+ ChefUtils::VersionString.new(node["languages"]["powershell"]["version"])
+ end
+
extend self
end
end
diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb
index 30fc92da36..fc54e6c4ac 100644
--- a/chef-utils/lib/chef-utils/version.rb
+++ b/chef-utils/lib/chef-utils/version.rb
@@ -15,5 +15,5 @@
module ChefUtils
CHEFUTILS_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "15.7.33".freeze
+ VERSION = "15.8.4".freeze
end