chef-utils 0.0.1 → 15.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/chef-utils.gemspec +11 -3
- data/lib/chef-utils.rb +43 -0
- data/lib/chef-utils/dsl/architecture.rb +117 -0
- data/lib/chef-utils/dsl/introspection.rb +93 -0
- data/lib/chef-utils/dsl/os.rb +55 -0
- data/lib/chef-utils/dsl/path_sanity.rb +58 -0
- data/lib/chef-utils/dsl/platform.rb +339 -0
- data/lib/chef-utils/dsl/platform_family.rb +314 -0
- data/lib/chef-utils/dsl/service.rb +91 -0
- data/lib/chef-utils/dsl/train_helpers.rb +63 -0
- data/lib/chef-utils/dsl/which.rb +118 -0
- data/lib/chef-utils/internal.rb +77 -0
- data/lib/chef-utils/mash.rb +239 -0
- data/lib/chef-utils/version.rb +1 -1
- data/spec/spec_helper.rb +93 -0
- data/spec/unit/dsl/architecture_spec.rb +139 -0
- data/spec/unit/dsl/dsl_spec.rb +33 -0
- data/spec/unit/dsl/introspection_spec.rb +168 -0
- data/spec/unit/dsl/os_spec.rb +174 -0
- data/spec/unit/dsl/path_sanity_spec.rb +85 -0
- data/spec/unit/dsl/platform_family_spec.rb +222 -0
- data/spec/unit/dsl/platform_spec.rb +234 -0
- data/spec/unit/dsl/service_spec.rb +116 -0
- data/spec/unit/dsl/which_spec.rb +168 -0
- data/spec/unit/mash_spec.rb +50 -0
- metadata +35 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b52b97bdb973d51382ed8a0594fb95f8be34727380d03d2a5929b3beb3156364
|
4
|
+
data.tar.gz: ae37e164b4891c0fdd66c5e90a75813906b2c70311b0ceff6ca3f505f83412d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a6d7ea11a8f15d308748723cd2376ac01f1dc90c713fdf9735cc57d83f59a725e6e2a4b0747b20f659a5ea2f39df91f36a0720aa908a798ac7f003000b4ea1
|
7
|
+
data.tar.gz: bb88ff0308fb16377e49de5c1a63bb4b6341bec4fa26eb9674ef17476b3a88f3080c7622eab48beb4bd5aa206a61d2ad852093664ae3b50ee9f1723e3f0d7931
|
data/chef-utils.gemspec
CHANGED
@@ -6,13 +6,21 @@ require "chef-utils/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "chef-utils"
|
8
8
|
spec.version = ChefUtils::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Chef Software, Inc"]
|
10
|
+
spec.email = ["oss@chef.io"]
|
11
11
|
|
12
12
|
spec.summary = %q{Basic utility functions for Core Chef development}
|
13
|
-
spec.homepage = "https://github.com/chef/chef"
|
13
|
+
spec.homepage = "https://github.com/chef/chef/tree/master/chef-utils"
|
14
14
|
spec.license = "Apache-2.0"
|
15
15
|
|
16
|
+
spec.metadata = {
|
17
|
+
"bug_tracker_uri" => "https://github.com/chef/chef/issues",
|
18
|
+
"changelog_uri" => "https://github.com/chef/chef/CHANGELOG.md",
|
19
|
+
"documentation_uri" => "https://github.com/chef/chef/tree/master/chef-utils/README.md",
|
20
|
+
"homepage_uri" => "https://github.com/chef/chef/tree/master/chef-utils",
|
21
|
+
"source_code_uri" => "https://github.com/chef/chef/tree/master/chef-utils",
|
22
|
+
}
|
23
|
+
|
16
24
|
spec.require_paths = ["lib"]
|
17
25
|
|
18
26
|
#
|
data/lib/chef-utils.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2015-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "chef-utils/dsl/architecture"
|
19
|
+
require_relative "chef-utils/dsl/introspection"
|
20
|
+
require_relative "chef-utils/dsl/os"
|
21
|
+
require_relative "chef-utils/dsl/path_sanity"
|
22
|
+
require_relative "chef-utils/dsl/platform"
|
23
|
+
require_relative "chef-utils/dsl/platform_family"
|
24
|
+
require_relative "chef-utils/dsl/service"
|
25
|
+
require_relative "chef-utils/dsl/train_helpers"
|
26
|
+
require_relative "chef-utils/dsl/which"
|
27
|
+
require_relative "chef-utils/mash"
|
28
|
+
|
29
|
+
# This is the Chef Infra Client DSL, not everytihng needs to go in here
|
30
|
+
module ChefUtils
|
31
|
+
include ChefUtils::DSL::Architecture
|
32
|
+
include ChefUtils::DSL::OS
|
33
|
+
include ChefUtils::DSL::PlatformFamily
|
34
|
+
include ChefUtils::DSL::Platform
|
35
|
+
include ChefUtils::DSL::Introspection
|
36
|
+
# FIXME: include ChefUtils::DSL::Which in Chef 16.0
|
37
|
+
# FIXME: include ChefUtils::DSL::PathSanity in Chef 16.0
|
38
|
+
# FIXME: include ChefUtils::DSL::TrainHelpers in Chef 16.0
|
39
|
+
# ChefUtils::DSL::Service is deliberately excluded
|
40
|
+
|
41
|
+
CANARY = 1 # used as a guard for requires
|
42
|
+
extend self
|
43
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "../internal"
|
19
|
+
|
20
|
+
module ChefUtils
|
21
|
+
module DSL
|
22
|
+
module Architecture
|
23
|
+
include Internal
|
24
|
+
|
25
|
+
# Determine if the current architecture is 64-bit
|
26
|
+
#
|
27
|
+
# @return [Boolean]
|
28
|
+
#
|
29
|
+
def _64_bit?(node = __getnode)
|
30
|
+
%w{amd64 x86_64 ppc64 ppc64le s390x ia64 sparc64 aarch64 arch64 arm64 sun4v sun4u}
|
31
|
+
.include?(node["kernel"]["machine"])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Determine if the current architecture is 32-bit
|
35
|
+
#
|
36
|
+
# @return [Boolean]
|
37
|
+
#
|
38
|
+
def _32_bit?(node = __getnode)
|
39
|
+
!_64_bit?(node)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Determine if the current architecture is i386
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
#
|
46
|
+
def i386?(node = __getnode)
|
47
|
+
_32_bit?(node) && intel?(node)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Determine if the current architecture is Intel.
|
51
|
+
#
|
52
|
+
# @return [Boolean]
|
53
|
+
#
|
54
|
+
def intel?(node = __getnode)
|
55
|
+
%w{i86pc i386 x86_64 amd64 i686}.include?(node["kernel"]["machine"])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Determine if the current architecture is SPARC.
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
#
|
62
|
+
def sparc?(node = __getnode)
|
63
|
+
%w{sun4u sun4v}.include?(node["kernel"]["machine"])
|
64
|
+
end
|
65
|
+
|
66
|
+
# Determine if the current architecture is Powerpc64 Big Endian
|
67
|
+
#
|
68
|
+
# @return [Boolean]
|
69
|
+
#
|
70
|
+
def ppc64?(node = __getnode)
|
71
|
+
%w{ppc64}.include?(node["kernel"]["machine"])
|
72
|
+
end
|
73
|
+
|
74
|
+
# Determine if the current architecture is Powerpc64 Little Endian
|
75
|
+
#
|
76
|
+
# @return [Boolean]
|
77
|
+
#
|
78
|
+
def ppc64le?(node = __getnode)
|
79
|
+
%w{ppc64le}.include?(node["kernel"]["machine"])
|
80
|
+
end
|
81
|
+
|
82
|
+
# Determine if the current architecture is PowerPC.
|
83
|
+
#
|
84
|
+
# @return [Boolean]
|
85
|
+
#
|
86
|
+
def powerpc?(node = __getnode)
|
87
|
+
%w{powerpc}.include?(node["kernel"]["machine"])
|
88
|
+
end
|
89
|
+
|
90
|
+
# Determine if the current architecture is 32-bit ARM
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
#
|
94
|
+
def armhf?(node = __getnode)
|
95
|
+
%w{armhf}.include?(node["kernel"]["machine"])
|
96
|
+
end
|
97
|
+
|
98
|
+
# Determine if the current architecture is s390x
|
99
|
+
#
|
100
|
+
# @return [Boolean]
|
101
|
+
#
|
102
|
+
def s390x?(node = __getnode)
|
103
|
+
%w{s390x}.include?(node["kernel"]["machine"])
|
104
|
+
end
|
105
|
+
|
106
|
+
# Determine if the current architecture is s390
|
107
|
+
#
|
108
|
+
# @return [Boolean]
|
109
|
+
#
|
110
|
+
def s390?(node = __getnode)
|
111
|
+
%w{s390}.include?(node["kernel"]["machine"])
|
112
|
+
end
|
113
|
+
|
114
|
+
extend self
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "train_helpers"
|
19
|
+
|
20
|
+
module ChefUtils
|
21
|
+
module DSL
|
22
|
+
# This is for "introspection" helpers in the sense that we are inspecting the
|
23
|
+
# actual server or image under management to determine running state (duck-typing the system).
|
24
|
+
# The helpers here may use the node object state from ohai, but typically not the big 5: platform,
|
25
|
+
# platform_family, platform_version, arch, os. The helpers here should infer somewhat
|
26
|
+
# higher level facts about the system.
|
27
|
+
#
|
28
|
+
module Introspection
|
29
|
+
include TrainHelpers
|
30
|
+
|
31
|
+
# Returns whether the node is a docker container.
|
32
|
+
#
|
33
|
+
# @param [Chef::Node] node
|
34
|
+
#
|
35
|
+
# @return [Boolean]
|
36
|
+
#
|
37
|
+
def docker?(node = __getnode)
|
38
|
+
# Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad,
|
39
|
+
# and that makes us sad too.
|
40
|
+
!!(node && node.read("virtualization", "systems", "docker") == "guest")
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [Chef::Node] node
|
44
|
+
#
|
45
|
+
# @return [Boolean]
|
46
|
+
#
|
47
|
+
def systemd?(node = __getnode)
|
48
|
+
file_exist?("/proc/1/comm") && file_open("/proc/1/comm").gets.chomp == "systemd"
|
49
|
+
end
|
50
|
+
|
51
|
+
# @param [Chef::Node] node
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
54
|
+
#
|
55
|
+
def kitchen?(node = __getnode)
|
56
|
+
ENV.key?("TEST_KITCHEN")
|
57
|
+
end
|
58
|
+
|
59
|
+
# @param [Chef::Node] node
|
60
|
+
#
|
61
|
+
# @return [Boolean]
|
62
|
+
#
|
63
|
+
def ci?(node = __getnode)
|
64
|
+
ENV.key?("CI")
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param [String] svc_name
|
68
|
+
#
|
69
|
+
# @return [Boolean]
|
70
|
+
#
|
71
|
+
def has_systemd_service_unit?(svc_name)
|
72
|
+
%w{ /etc /usr/lib /lib /run }.any? do |load_path|
|
73
|
+
file_exist?(
|
74
|
+
"#{load_path}/systemd/system/#{svc_name.gsub(/@.*$/, "@")}.service"
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# @param [String] svc_name
|
80
|
+
#
|
81
|
+
# @return [Boolean]
|
82
|
+
#
|
83
|
+
def has_systemd_unit?(svc_name)
|
84
|
+
# TODO: stop supporting non-service units with service resource
|
85
|
+
%w{ /etc /usr/lib /lib /run }.any? do |load_path|
|
86
|
+
file_exist?("#{load_path}/systemd/system/#{svc_name}")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
extend self
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "../internal"
|
19
|
+
|
20
|
+
module ChefUtils
|
21
|
+
module DSL
|
22
|
+
module OS
|
23
|
+
include Internal
|
24
|
+
|
25
|
+
#
|
26
|
+
# NOTE CAREFULLY: Most node['os'] values should not appear in this file at all.
|
27
|
+
#
|
28
|
+
# For cases where node['os'] == node['platform_family'] == node['platform'] then
|
29
|
+
# only the platform helper should be added.
|
30
|
+
#
|
31
|
+
|
32
|
+
# Determine if the current node is linux.
|
33
|
+
#
|
34
|
+
# @param [Chef::Node] node
|
35
|
+
#
|
36
|
+
# @return [Boolean]
|
37
|
+
#
|
38
|
+
def linux?(node = __getnode)
|
39
|
+
node["os"] == "linux"
|
40
|
+
end
|
41
|
+
|
42
|
+
# Determine if the current node is darwin.
|
43
|
+
#
|
44
|
+
# @param [Chef::Node] node
|
45
|
+
#
|
46
|
+
# @return [Boolean]
|
47
|
+
#
|
48
|
+
def darwin?(node = __getnode)
|
49
|
+
node["os"] == "darwin"
|
50
|
+
end
|
51
|
+
|
52
|
+
extend self
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "../internal"
|
19
|
+
require_relative "platform_family"
|
20
|
+
|
21
|
+
module ChefUtils
|
22
|
+
module DSL
|
23
|
+
module PathSanity
|
24
|
+
include Internal
|
25
|
+
|
26
|
+
def sanitized_path(env = nil)
|
27
|
+
env_path = env ? env["PATH"] : __env_path
|
28
|
+
env_path = "" if env_path.nil?
|
29
|
+
path_separator = ChefUtils.windows? ? ";" : ":"
|
30
|
+
# ensure the Ruby and Gem bindirs are included for omnibus chef installs
|
31
|
+
new_paths = env_path.split(path_separator)
|
32
|
+
[ ChefUtils::DSL::PathSanity.ruby_bindir, ChefUtils::DSL::PathSanity.gem_bindir ].compact.each do |path|
|
33
|
+
new_paths = [ path ] + new_paths unless new_paths.include?(path)
|
34
|
+
end
|
35
|
+
ChefUtils::DSL::PathSanity.sane_paths.each do |path|
|
36
|
+
new_paths << path unless new_paths.include?(path)
|
37
|
+
end
|
38
|
+
new_paths.join(path_separator).encode("utf-8", invalid: :replace, undef: :replace)
|
39
|
+
end
|
40
|
+
|
41
|
+
class << self
|
42
|
+
def sane_paths
|
43
|
+
ChefUtils.windows? ? %w{} : %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}
|
44
|
+
end
|
45
|
+
|
46
|
+
def ruby_bindir
|
47
|
+
RbConfig::CONFIG["bindir"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def gem_bindir
|
51
|
+
Gem.bindir
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
extend self
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,339 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright 2018-2019, Chef Software Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require_relative "../internal"
|
19
|
+
|
20
|
+
module ChefUtils
|
21
|
+
module DSL
|
22
|
+
module Platform
|
23
|
+
include Internal
|
24
|
+
|
25
|
+
# NOTE: if you are adding new platform helpers they should all have the `_platform?` suffix.
|
26
|
+
# DO NOT add new short aliases without the suffix (they will be deprecated in the future)
|
27
|
+
# aliases here are mostly for backwards compatibility with chef-sugar and new ones are DISCOURAGED.
|
28
|
+
# generally there should be one obviously correct way to do things.
|
29
|
+
|
30
|
+
# Determine if the current node is linux mint.
|
31
|
+
#
|
32
|
+
# @param [Chef::Node] node
|
33
|
+
#
|
34
|
+
# @return [Boolean]
|
35
|
+
#
|
36
|
+
def linuxmint?(node = __getnode)
|
37
|
+
node["platform"] == "linuxmint"
|
38
|
+
end
|
39
|
+
# chef-sugar backcompat methods
|
40
|
+
alias_method :mint?, :linuxmint?
|
41
|
+
alias_method :linux_mint?, :linuxmint?
|
42
|
+
alias_method :linuxmint_platform?, :linuxmint?
|
43
|
+
|
44
|
+
# Determine if the current node is ubuntu.
|
45
|
+
#
|
46
|
+
# @param [Chef::Node] node
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
#
|
50
|
+
def ubuntu?(node = __getnode)
|
51
|
+
node["platform"] == "ubuntu"
|
52
|
+
end
|
53
|
+
alias_method :ubuntu_platform?, :ubuntu?
|
54
|
+
|
55
|
+
# Determine if the current node is raspbian.
|
56
|
+
#
|
57
|
+
# @param [Chef::Node] node
|
58
|
+
#
|
59
|
+
# @return [Boolean]
|
60
|
+
#
|
61
|
+
def raspbian?(node = __getnode)
|
62
|
+
node["platform"] == "raspbian"
|
63
|
+
end
|
64
|
+
alias_method :raspbian_platform?, :raspbian?
|
65
|
+
|
66
|
+
# Determine if the current node is debian.
|
67
|
+
#
|
68
|
+
# @param [Chef::Node] node
|
69
|
+
#
|
70
|
+
# @return [Boolean]
|
71
|
+
#
|
72
|
+
def debian_platform?(node = __getnode)
|
73
|
+
node["platform"] == "debian"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Determine if the current node is amazon linux.
|
77
|
+
#
|
78
|
+
# @param [Chef::Node] node
|
79
|
+
#
|
80
|
+
# @return [Boolean]
|
81
|
+
#
|
82
|
+
def amazon_platform?(node = __getnode)
|
83
|
+
node["platform"] == "amazon"
|
84
|
+
end
|
85
|
+
|
86
|
+
# Determine if the current node is redhat enterprise.
|
87
|
+
#
|
88
|
+
# @param [Chef::Node] node
|
89
|
+
#
|
90
|
+
# @return [Boolean]
|
91
|
+
#
|
92
|
+
def redhat?(node = __getnode)
|
93
|
+
node["platform"] == "redhat"
|
94
|
+
end
|
95
|
+
# chef-sugar backcompat methods
|
96
|
+
alias_method :redhat_enterprise?, :redhat?
|
97
|
+
alias_method :redhat_enterprise_linux?, :redhat?
|
98
|
+
alias_method :redhat_platform?, :redhat?
|
99
|
+
|
100
|
+
# Determine if the current node is centos.
|
101
|
+
#
|
102
|
+
# @param [Chef::Node] node
|
103
|
+
#
|
104
|
+
# @return [Boolean]
|
105
|
+
#
|
106
|
+
def centos?(node = __getnode)
|
107
|
+
node["platform"] == "centos"
|
108
|
+
end
|
109
|
+
alias_method :centos_platform?, :centos?
|
110
|
+
|
111
|
+
# Determine if the current node is oracle linux.
|
112
|
+
#
|
113
|
+
# @param [Chef::Node] node
|
114
|
+
#
|
115
|
+
# @return [Boolean]
|
116
|
+
#
|
117
|
+
def oracle?(node = __getnode)
|
118
|
+
node["platform"] == "oracle"
|
119
|
+
end
|
120
|
+
# chef-sugar backcompat methods
|
121
|
+
alias_method :oracle_linux?, :oracle?
|
122
|
+
alias_method :oracle_platform?, :oracle?
|
123
|
+
|
124
|
+
# Determine if the current node is scientific linux.
|
125
|
+
#
|
126
|
+
# @param [Chef::Node] node
|
127
|
+
#
|
128
|
+
# @return [Boolean]
|
129
|
+
#
|
130
|
+
def scientific?(node = __getnode)
|
131
|
+
node["platform"] == "scientific"
|
132
|
+
end
|
133
|
+
# chef-sugar backcompat methods
|
134
|
+
alias_method :scientific_linux?, :scientific?
|
135
|
+
alias_method :scientific_platform?, :scientific?
|
136
|
+
|
137
|
+
# Determine if the current node is clearos.
|
138
|
+
#
|
139
|
+
# @param [Chef::Node] node
|
140
|
+
#
|
141
|
+
# @return [Boolean]
|
142
|
+
#
|
143
|
+
def clearos?(node = __getnode)
|
144
|
+
node["platform"] == "clearos"
|
145
|
+
end
|
146
|
+
alias_method :clearos_platform?, :clearos?
|
147
|
+
|
148
|
+
# Determine if the current node is fedora.
|
149
|
+
#
|
150
|
+
# @param [Chef::Node] node
|
151
|
+
#
|
152
|
+
# @return [Boolean]
|
153
|
+
#
|
154
|
+
def fedora_platform?(node = __getnode)
|
155
|
+
node["platform"] == "fedora"
|
156
|
+
end
|
157
|
+
|
158
|
+
# Determine if the current node is arch
|
159
|
+
#
|
160
|
+
# @param [Chef::Node] node
|
161
|
+
#
|
162
|
+
# @return [Boolean]
|
163
|
+
#
|
164
|
+
def arch_platform?(node = __getnode)
|
165
|
+
node["platform"] == "arch"
|
166
|
+
end
|
167
|
+
|
168
|
+
# Determine if the current node is solaris2
|
169
|
+
#
|
170
|
+
# @param [Chef::Node] node
|
171
|
+
#
|
172
|
+
# @return [Boolean]
|
173
|
+
#
|
174
|
+
def solaris2_platform?(node = __getnode)
|
175
|
+
node["platform"] == "solaris2"
|
176
|
+
end
|
177
|
+
|
178
|
+
# Determine if the current node is smartos
|
179
|
+
#
|
180
|
+
# @param [Chef::Node] node
|
181
|
+
#
|
182
|
+
# @return [Boolean]
|
183
|
+
#
|
184
|
+
def smartos_platform?(node = __getnode)
|
185
|
+
node["platform"] == "smartos"
|
186
|
+
end
|
187
|
+
|
188
|
+
# Determine if the current node is omnios
|
189
|
+
#
|
190
|
+
# @param [Chef::Node] node
|
191
|
+
#
|
192
|
+
# @return [Boolean]
|
193
|
+
#
|
194
|
+
def omnios?(node = __getnode)
|
195
|
+
node["platform"] == "omnios"
|
196
|
+
end
|
197
|
+
alias_method :omnios_platform?, :omnios?
|
198
|
+
|
199
|
+
# Determine if the current node is openindiana
|
200
|
+
#
|
201
|
+
# @param [Chef::Node] node
|
202
|
+
#
|
203
|
+
# @return [Boolean]
|
204
|
+
#
|
205
|
+
def openindiana?(node = __getnode)
|
206
|
+
node["platform"] == "openindiana"
|
207
|
+
end
|
208
|
+
alias_method :openindiana_platform?, :openindiana?
|
209
|
+
|
210
|
+
# Determine if the current node is nexentacore
|
211
|
+
#
|
212
|
+
# @param [Chef::Node] node
|
213
|
+
#
|
214
|
+
# @return [Boolean]
|
215
|
+
#
|
216
|
+
def nexentacore?(node = __getnode)
|
217
|
+
node["platform"] == "nexentacore"
|
218
|
+
end
|
219
|
+
alias_method :nexentacore_platform?, :nexentacore?
|
220
|
+
|
221
|
+
# Determine if the current node is aix
|
222
|
+
#
|
223
|
+
# @param [Chef::Node] node
|
224
|
+
#
|
225
|
+
# @return [Boolean]
|
226
|
+
#
|
227
|
+
def aix_platform?(node = __getnode)
|
228
|
+
node["platform"] == "aix"
|
229
|
+
end
|
230
|
+
|
231
|
+
# Determine if the current node is freebsd
|
232
|
+
#
|
233
|
+
# @param [Chef::Node] node
|
234
|
+
#
|
235
|
+
# @return [Boolean]
|
236
|
+
#
|
237
|
+
def freebsd_platform?(node = __getnode)
|
238
|
+
node["platform"] == "freebsd"
|
239
|
+
end
|
240
|
+
|
241
|
+
# Determine if the current node is openbsd
|
242
|
+
#
|
243
|
+
# @param [Chef::Node] node
|
244
|
+
#
|
245
|
+
# @return [Boolean]
|
246
|
+
#
|
247
|
+
def openbsd_platform?(node = __getnode)
|
248
|
+
node["platform"] == "openbsd"
|
249
|
+
end
|
250
|
+
|
251
|
+
# Determine if the current node is netbsd
|
252
|
+
#
|
253
|
+
# @param [Chef::Node] node
|
254
|
+
#
|
255
|
+
# @return [Boolean]
|
256
|
+
#
|
257
|
+
def netbsd_platform?(node = __getnode)
|
258
|
+
node["platform"] == "netbsd"
|
259
|
+
end
|
260
|
+
|
261
|
+
# Determine if the current node is dragonflybsd
|
262
|
+
#
|
263
|
+
# @param [Chef::Node] node
|
264
|
+
#
|
265
|
+
# @return [Boolean]
|
266
|
+
#
|
267
|
+
def dragonfly_platform?(node = __getnode)
|
268
|
+
node["platform"] == "dragonfly"
|
269
|
+
end
|
270
|
+
|
271
|
+
# Determine if the current node is MacOS.
|
272
|
+
#
|
273
|
+
# @param [Chef::Node] node
|
274
|
+
#
|
275
|
+
# @return [Boolean]
|
276
|
+
#
|
277
|
+
def macos_platform?(node = __getnode)
|
278
|
+
node["platform"] == "mac_os_x"
|
279
|
+
end
|
280
|
+
alias_method :mac_os_x_platform?, :macos_platform?
|
281
|
+
|
282
|
+
# Determine if the current node is gentoo
|
283
|
+
#
|
284
|
+
# @param [Chef::Node] node
|
285
|
+
#
|
286
|
+
# @return [Boolean]
|
287
|
+
#
|
288
|
+
def gentoo_platform?(node = __getnode)
|
289
|
+
node["platform"] == "gentoo"
|
290
|
+
end
|
291
|
+
|
292
|
+
# Determine if the current node is slackware.
|
293
|
+
#
|
294
|
+
# @param [Chef::Node] node
|
295
|
+
#
|
296
|
+
# @return [Boolean]
|
297
|
+
#
|
298
|
+
def slackware_platform?(node = __getnode)
|
299
|
+
node["platform"] == "slackware"
|
300
|
+
end
|
301
|
+
|
302
|
+
# Determine if the current node is SuSE.
|
303
|
+
#
|
304
|
+
# @param [Chef::Node] node
|
305
|
+
#
|
306
|
+
# @return [Boolean]
|
307
|
+
#
|
308
|
+
def suse_platform?(node = __getnode)
|
309
|
+
node["platform"] == "suse"
|
310
|
+
end
|
311
|
+
|
312
|
+
# Determine if the current node is OpenSuSE.
|
313
|
+
#
|
314
|
+
# @param [Chef::Node] node
|
315
|
+
#
|
316
|
+
# @return [Boolean]
|
317
|
+
#
|
318
|
+
def opensuse?(node = __getnode)
|
319
|
+
node["platform"] == "opensuse" || node["platform"] == "opensuseleap"
|
320
|
+
end
|
321
|
+
alias_method :opensuse_platform?, :opensuse?
|
322
|
+
alias_method :opensuseleap_platform?, :opensuse?
|
323
|
+
alias_method :leap_platform?, :opensuse?
|
324
|
+
# NOTE: to anyone adding :tumbleweed_platform? - :[opensuse]leap_platform? should be false on tumbleweed, :opensuse[_platform]? should be true
|
325
|
+
|
326
|
+
# Determine if the current node is Windows.
|
327
|
+
#
|
328
|
+
# @param [Chef::Node] node
|
329
|
+
#
|
330
|
+
# @return [Boolean]
|
331
|
+
#
|
332
|
+
def windows_platform?(node = __getnode)
|
333
|
+
node["platform"] == "windows"
|
334
|
+
end
|
335
|
+
|
336
|
+
extend self
|
337
|
+
end
|
338
|
+
end
|
339
|
+
end
|