Module: ChefUtils::DSL::PlatformFamily
- Extended by:
- PlatformFamily
- Includes:
- Internal
- Included in:
- ChefUtils, PlatformFamily
- Defined in:
- lib/chef-utils/dsl/platform_family.rb
Instance Method Summary collapse
-
#aix?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘aix’ platform family.
-
#amazon?(node = __getnode) ⇒ Boolean
(also: #amazon_linux?)
Determine if the current node is a member of the ‘amazon’ platform family.
-
#arch?(node = __getnode) ⇒ Boolean
(also: #arch_linux?)
Determine if the current node is a member of the ‘arch’ family.
-
#bsd_based?(node = __getnode) ⇒ Boolean
All of the BSD-lineage.
-
#debian?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘debian’ platform family (Debian, Ubuntu and derivatives).
-
#dragonflybsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘dragonflybsd’ platform family.
-
#fedora?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘fedora’ platform family (Fedora and Arista).
-
#fedora_derived?(node = __getnode) ⇒ Boolean
RPM-based distros which are not SuSE and are very loosely similar to fedora, using yum or dnf.
-
#freebsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘freebsd’ platform family.
-
#gentoo?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘gentoo’ platform family.
-
#macos?(node = __getnode) ⇒ Boolean
(also: #osx?, #mac?, #mac_os_x?)
Determine if the current node is a member of the ‘mac_os_x’ platform family.
-
#macos_ruby? ⇒ Boolean
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).
-
#netbsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘netbsd’ platform family.
-
#openbsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘openbsd’ platform family.
-
#redhat_based?(node = __getnode) ⇒ Boolean
RedHat distros – fedora and rhel platform_families, nothing else.
-
#rhel6?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
-
#rhel7?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel7 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
-
#rhel8?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel8 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
-
#rhel?(node = __getnode) ⇒ Boolean
(also: #el?)
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).
-
#rpm_based?(node = __getnode) ⇒ Boolean
If it uses RPM, it goes in here (rhel, fedora, amazon, suse platform_families).
-
#smartos?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘smartos’ platform family.
-
#solaris2?(node = __getnode) ⇒ Boolean
(also: #solaris?)
Determine if the current node is a member of the ‘solaris2’ platform family.
-
#solaris_based?(node = __getnode) ⇒ Boolean
All of the Solaris-lineage.
-
#suse?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘suse’ platform family (openSUSE, SLES, and SLED).
-
#windows?(node = __getnode(true)) ⇒ Boolean
Determine if the current node is a member of the ‘windows’ platform family.
-
#windows_ruby? ⇒ Boolean
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).
Instance Method Details
#aix?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘aix’ platform family.
46 47 48 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 46 def aix?(node = __getnode) node["platform_family"] == "aix" end |
#amazon?(node = __getnode) ⇒ Boolean Also known as: amazon_linux?
Determine if the current node is a member of the ‘amazon’ platform family.
153 154 155 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 153 def amazon?(node = __getnode) node["platform_family"] == "amazon" end |
#arch?(node = __getnode) ⇒ Boolean Also known as: arch_linux?
Determine if the current node is a member of the ‘arch’ family.
33 34 35 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 33 def arch?(node = __getnode) node["platform_family"] == "arch" end |
#bsd_based?(node = __getnode) ⇒ Boolean
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.
352 353 354 355 |
# 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 |
#debian?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘debian’ platform family (Debian, Ubuntu and derivatives).
57 58 59 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 57 def debian?(node = __getnode) node["platform_family"] == "debian" end |
#dragonflybsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘dragonflybsd’ platform family.
245 246 247 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 245 def dragonflybsd?(node = __getnode) node["platform_family"] == "dragonflybsd" end |
#fedora?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘fedora’ platform family (Fedora and Arista).
68 69 70 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 68 def fedora?(node = __getnode) node["platform_family"] == "fedora" end |
#fedora_derived?(node = __getnode) ⇒ Boolean
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”.
316 317 318 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 316 def fedora_derived?(node = __getnode) redhat_based?(node) || node["platform_family"] == "amazon" end |
#freebsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘freebsd’ platform family.
212 213 214 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 212 def freebsd?(node = __getnode) node["platform_family"] == "freebsd" end |
#gentoo?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘gentoo’ platform family.
201 202 203 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 201 def gentoo?(node = __getnode) node["platform_family"] == "gentoo" end |
#macos?(node = __getnode) ⇒ Boolean Also known as: osx?, mac?, mac_os_x?
Determine if the current node is a member of the ‘mac_os_x’ platform family.
79 80 81 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 79 def macos?(node = __getnode) node ? node["platform_family"] == "mac_os_x" : macos_ruby? end |
#macos_ruby? ⇒ Boolean
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).
96 97 98 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 96 def macos_ruby? !!(RUBY_PLATFORM =~ /darwin/) end |
#netbsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘netbsd’ platform family.
234 235 236 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 234 def netbsd?(node = __getnode) node["platform_family"] == "netbsd" end |
#openbsd?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘openbsd’ platform family.
223 224 225 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 223 def openbsd?(node = __getnode) node["platform_family"] == "openbsd" end |
#redhat_based?(node = __getnode) ⇒ Boolean
RedHat distros – fedora and rhel platform_families, nothing else. This is most likely not as useful as the “fedora_derived?” helper.
328 329 330 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 328 def redhat_based?(node = __getnode) %w{rhel fedora}.include?(node["platform_family"]) end |
#rhel6?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
120 121 122 |
# 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 |
#rhel7?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel7 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
131 132 133 |
# 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 |
#rhel8?(node = __getnode) ⇒ Boolean
Determine if the current node is a rhel8 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
142 143 144 |
# 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 |
#rhel?(node = __getnode) ⇒ Boolean Also known as: el?
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).
107 108 109 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 107 def rhel?(node = __getnode) node["platform_family"] == "rhel" end |
#rpm_based?(node = __getnode) ⇒ Boolean
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”.
303 304 305 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 303 def rpm_based?(node = __getnode) fedora_derived?(node) || node["platform_family"] == "suse" end |
#smartos?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘smartos’ platform family.
179 180 181 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 179 def smartos?(node = __getnode) node["platform_family"] == "smartos" end |
#solaris2?(node = __getnode) ⇒ Boolean Also known as: solaris?
Determine if the current node is a member of the ‘solaris2’ platform family.
166 167 168 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 166 def solaris2?(node = __getnode) node["platform_family"] == "solaris2" end |
#solaris_based?(node = __getnode) ⇒ Boolean
All of the Solaris-lineage.
339 340 341 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 339 def solaris_based?(node = __getnode) %w{solaris2 smartos omnios openindiana}.include?(node["platform"]) end |
#suse?(node = __getnode) ⇒ Boolean
Determine if the current node is a member of the ‘suse’ platform family (openSUSE, SLES, and SLED).
190 191 192 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 190 def suse?(node = __getnode) node["platform_family"] == "suse" end |
#windows?(node = __getnode(true)) ⇒ Boolean
Determine if the current node is a member of the ‘windows’ platform family.
256 257 258 259 260 261 262 263 264 265 266 267 268 |
# 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 |
#windows_ruby? ⇒ Boolean
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
282 283 284 |
# File 'lib/chef-utils/dsl/platform_family.rb', line 282 def windows_ruby? !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) end |