module ChefUtils::DSL::PlatformFamily
Public Instance Methods
Source
# File lib/chef-utils/dsl/platform_family.rb, line 46 def aix?(node = __getnode) node["platform_family"] == "aix" end
Determine if the current node is a member of the âaixâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 153 def amazon?(node = __getnode) node["platform_family"] == "amazon" end
Determine if the current node is a member of the âamazonâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 33 def arch?(node = __getnode) node["platform_family"] == "arch" end
Determine if the current node is a member of the âarchâ family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 352 def bsd_based?(node = __getnode) # we could use os, platform_family or platform here equally %w{netbsd freebsd openbsd dragonflybsd}.include?(node["platform"]) end
All of the BSD-lineage.
Note that macOS is not included since macOS deviates so significantly from BSD that including it would not be useful.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 57 def debian?(node = __getnode) node["platform_family"] == "debian" end
Determine if the current node is a member of the âdebianâ platform family (Debian, Ubuntu and derivatives).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 245 def dragonflybsd?(node = __getnode) node["platform_family"] == "dragonflybsd" end
Determine if the current node is a member of the âdragonflybsdâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 68 def fedora?(node = __getnode) node["platform_family"] == "fedora" end
Determine if the current node is a member of the âfedoraâ platform family (Fedora and Arista).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 316 def fedora_derived?(node = __getnode) redhat_based?(node) || node["platform_family"] == "amazon" end
RPM-based distros which are not SuSE and are very loosely similar to fedora, using yum or dnf. The historical lineage of the distro should have forked off from old redhat fedora distros at some point. Currently rhel, fedora and amazon. This is most useful for âsmells like redhat, but isnât SuSEâ.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 212 def freebsd?(node = __getnode) node["platform_family"] == "freebsd" end
Determine if the current node is a member of the âfreebsdâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 201 def gentoo?(node = __getnode) node["platform_family"] == "gentoo" end
Determine if the current node is a member of the âgentooâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 79 def macos?(node = __getnode) node ? node["platform_family"] == "mac_os_x" : macos_ruby? end
Determine if the current node is a member of the âmac_os_xâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 96 def macos_ruby? !!(RUBY_PLATFORM =~ /darwin/) end
Determine if the Ruby VM is currently running on a Mac node (This is useful primarily for internal use by Chef Infra Client before the node object exists).
@since 17.3
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 234 def netbsd?(node = __getnode) node["platform_family"] == "netbsd" end
Determine if the current node is a member of the ânetbsdâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 223 def openbsd?(node = __getnode) node["platform_family"] == "openbsd" end
Determine if the current node is a member of the âopenbsdâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 328 def redhat_based?(node = __getnode) %w{rhel fedora}.include?(node["platform_family"]) end
RedHat distros â fedora and rhel platform_families, nothing else. This is most likely not as useful as the âfedora_derived?â helper.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 120 def rhel6?(node = __getnode) node["platform_family"] == "rhel" && node["platform_version"].to_f >= 6.0 && node["platform_version"].to_f < 7.0 end
Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 131 def rhel7?(node = __getnode) node["platform_family"] == "rhel" && node["platform_version"].to_f >= 7.0 && node["platform_version"].to_f < 8.0 end
Determine if the current node is a rhel7 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 142 def rhel8?(node = __getnode) node["platform_family"] == "rhel" && node["platform_version"].to_f >= 8.0 && node["platform_version"].to_f < 9.0 end
Determine if the current node is a rhel8 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 107 def rhel?(node = __getnode) node["platform_family"] == "rhel" end
Determine if the current node is a member of the ârhelâ platform family (Red Hat, CentOS, Oracle or Scientific Linux, but NOT Amazon Linux or Fedora).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 303 def rpm_based?(node = __getnode) fedora_derived?(node) || node["platform_family"] == "suse" end
If it uses RPM, it goes in here (rhel, fedora, amazon, suse platform_families). Deliberately does not include AIX because bff is AIXâs primary package manager and adding it here would make this substantially less useful since in no way can AIX trace its lineage back to old redhat distros. This is most useful for âsmells like redhat, including SuSEâ.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 179 def smartos?(node = __getnode) node["platform_family"] == "smartos" end
Determine if the current node is a member of the âsmartosâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 166 def solaris2?(node = __getnode) node["platform_family"] == "solaris2" end
Determine if the current node is a member of the âsolaris2â platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 339 def solaris_based?(node = __getnode) %w{solaris2 smartos omnios openindiana}.include?(node["platform"]) end
All of the Solaris-lineage.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 190 def suse?(node = __getnode) node["platform_family"] == "suse" end
Determine if the current node is a member of the âsuseâ platform family (openSUSE, SLES, and SLED).
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 256 def windows?(node = __getnode(true)) # This is all somewhat complicated. We prefer to get the node object so that chefspec can # stub the node object. But we also have to deal with class-parsing time where there is # no node object, so we have to fall back to RUBY_PLATFORM based detection. We cannot pull # the node object out of the Chef.run_context.node global object here (which is what the # false flag to __getnode is about) because some run-time code also cannot run under chefspec # on non-windows where the node is stubbed to windows. # # As a result of this the `windows?` helper and the `ChefUtils.windows?` helper do not behave # the same way in that the latter is not stubbable by chefspec. # node ? node["platform_family"] == "windows" : windows_ruby? end
Determine if the current node is a member of the âwindowsâ platform family.
@param [Chef::Node] node the node to check @since 15.5
@return [Boolean]
Source
# File lib/chef-utils/dsl/platform_family.rb, line 282 def windows_ruby? !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) end
Determine if the Ruby VM is currently running on a Windows node (ChefSpec can never stub this behavior, so this is useful for code which can never be parsed on a non-Windows box).
April 2022 - Note that we changed the platform identifier from âmingw32â to âmingwâ We did this because Ruby 3.1 introduces the new universal windows platform of âx64-mingw-ucrtâ We updated the existing regex snippet to capture both the 32-bit platform and the new x64 universal platform
@since 15.5
@return [Boolean]