chef-utils 15.8.23 → 15.12.22
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/lib/chef-utils.rb +1 -1
- data/lib/chef-utils/dsl/architecture.rb +42 -10
- data/lib/chef-utils/dsl/cloud.rb +32 -23
- data/lib/chef-utils/dsl/introspection.rb +12 -5
- data/lib/chef-utils/dsl/os.rb +7 -5
- data/lib/chef-utils/dsl/path_sanity.rb +2 -1
- data/lib/chef-utils/dsl/platform.rb +57 -29
- data/lib/chef-utils/dsl/platform_family.rb +61 -35
- data/lib/chef-utils/dsl/platform_version.rb +1 -1
- data/lib/chef-utils/dsl/service.rb +11 -1
- data/lib/chef-utils/dsl/train_helpers.rb +2 -2
- data/lib/chef-utils/dsl/virtualization.rb +2 -2
- data/lib/chef-utils/dsl/which.rb +5 -5
- data/lib/chef-utils/dsl/windows.rb +14 -9
- data/lib/chef-utils/internal.rb +2 -2
- data/lib/chef-utils/version.rb +2 -2
- data/spec/unit/dsl/architecture_spec.rb +16 -5
- data/spec/unit/dsl/cloud_spec.rb +7 -1
- data/spec/unit/dsl/dsl_spec.rb +1 -1
- data/spec/unit/dsl/introspection_spec.rb +2 -2
- data/spec/unit/dsl/os_spec.rb +1 -1
- data/spec/unit/dsl/path_sanity_spec.rb +1 -1
- data/spec/unit/dsl/platform_family_spec.rb +1 -1
- data/spec/unit/dsl/platform_spec.rb +1 -1
- data/spec/unit/dsl/service_spec.rb +1 -1
- data/spec/unit/dsl/virtualization_spec.rb +1 -1
- data/spec/unit/dsl/which_spec.rb +1 -1
- data/spec/unit/dsl/windows_spec.rb +1 -1
- data/spec/unit/mash_spec.rb +1 -1
- metadata +2 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -24,7 +24,8 @@ module ChefUtils
|
|
24
24
|
|
25
25
|
# Determine if the current node is a member of the 'arch' family.
|
26
26
|
#
|
27
|
-
# @param [Chef::Node] node
|
27
|
+
# @param [Chef::Node] node the node to check
|
28
|
+
# @since 15.5
|
28
29
|
#
|
29
30
|
# @return [Boolean]
|
30
31
|
#
|
@@ -36,7 +37,8 @@ module ChefUtils
|
|
36
37
|
|
37
38
|
# Determine if the current node is a member of the 'aix' platform family.
|
38
39
|
#
|
39
|
-
# @param [Chef::Node] node
|
40
|
+
# @param [Chef::Node] node the node to check
|
41
|
+
# @since 15.5
|
40
42
|
#
|
41
43
|
# @return [Boolean]
|
42
44
|
#
|
@@ -46,7 +48,8 @@ module ChefUtils
|
|
46
48
|
|
47
49
|
# Determine if the current node is a member of the 'debian' platform family (Debian, Ubuntu and derivatives).
|
48
50
|
#
|
49
|
-
# @param [Chef::Node] node
|
51
|
+
# @param [Chef::Node] node the node to check
|
52
|
+
# @since 15.5
|
50
53
|
#
|
51
54
|
# @return [Boolean]
|
52
55
|
#
|
@@ -54,9 +57,10 @@ module ChefUtils
|
|
54
57
|
node["platform_family"] == "debian"
|
55
58
|
end
|
56
59
|
|
57
|
-
# Determine if the current node is a member of the 'fedora' platform family (Fedora and
|
60
|
+
# Determine if the current node is a member of the 'fedora' platform family (Fedora and Arista).
|
58
61
|
#
|
59
|
-
# @param [Chef::Node] node
|
62
|
+
# @param [Chef::Node] node the node to check
|
63
|
+
# @since 15.5
|
60
64
|
#
|
61
65
|
# @return [Boolean]
|
62
66
|
#
|
@@ -66,7 +70,8 @@ module ChefUtils
|
|
66
70
|
|
67
71
|
# Determine if the current node is a member of the 'mac_os_x' platform family.
|
68
72
|
#
|
69
|
-
# @param [Chef::Node] node
|
73
|
+
# @param [Chef::Node] node the node to check
|
74
|
+
# @since 15.5
|
70
75
|
#
|
71
76
|
# @return [Boolean]
|
72
77
|
#
|
@@ -82,7 +87,8 @@ module ChefUtils
|
|
82
87
|
|
83
88
|
# 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).
|
84
89
|
#
|
85
|
-
# @param [Chef::Node] node
|
90
|
+
# @param [Chef::Node] node the node to check
|
91
|
+
# @since 15.5
|
86
92
|
#
|
87
93
|
# @return [Boolean]
|
88
94
|
#
|
@@ -94,7 +100,8 @@ module ChefUtils
|
|
94
100
|
|
95
101
|
# Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
|
96
102
|
#
|
97
|
-
# @param [Chef::Node] node
|
103
|
+
# @param [Chef::Node] node the node to check
|
104
|
+
# @since 15.5
|
98
105
|
#
|
99
106
|
# @return [Boolean]
|
100
107
|
#
|
@@ -104,7 +111,8 @@ module ChefUtils
|
|
104
111
|
|
105
112
|
# Determine if the current node is a rhel7 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
|
106
113
|
#
|
107
|
-
# @param [Chef::Node] node
|
114
|
+
# @param [Chef::Node] node the node to check
|
115
|
+
# @since 15.5
|
108
116
|
#
|
109
117
|
# @return [Boolean]
|
110
118
|
#
|
@@ -114,7 +122,8 @@ module ChefUtils
|
|
114
122
|
|
115
123
|
# Determine if the current node is a rhel8 compatible build (Red Hat, CentOS, Oracle or Scientific Linux).
|
116
124
|
#
|
117
|
-
# @param [Chef::Node] node
|
125
|
+
# @param [Chef::Node] node the node to check
|
126
|
+
# @since 15.5
|
118
127
|
#
|
119
128
|
# @return [Boolean]
|
120
129
|
#
|
@@ -124,7 +133,8 @@ module ChefUtils
|
|
124
133
|
|
125
134
|
# Determine if the current node is a member of the 'amazon' platform family.
|
126
135
|
#
|
127
|
-
# @param [Chef::Node] node
|
136
|
+
# @param [Chef::Node] node the node to check
|
137
|
+
# @since 15.5
|
128
138
|
#
|
129
139
|
# @return [Boolean]
|
130
140
|
#
|
@@ -136,7 +146,8 @@ module ChefUtils
|
|
136
146
|
|
137
147
|
# Determine if the current node is a member of the 'solaris2' platform family.
|
138
148
|
#
|
139
|
-
# @param [Chef::Node] node
|
149
|
+
# @param [Chef::Node] node the node to check
|
150
|
+
# @since 15.5
|
140
151
|
#
|
141
152
|
# @return [Boolean]
|
142
153
|
#
|
@@ -148,7 +159,8 @@ module ChefUtils
|
|
148
159
|
|
149
160
|
# Determine if the current node is a member of the 'smartos' platform family.
|
150
161
|
#
|
151
|
-
# @param [Chef::Node] node
|
162
|
+
# @param [Chef::Node] node the node to check
|
163
|
+
# @since 15.5
|
152
164
|
#
|
153
165
|
# @return [Boolean]
|
154
166
|
#
|
@@ -156,9 +168,10 @@ module ChefUtils
|
|
156
168
|
node["platform_family"] == "smartos"
|
157
169
|
end
|
158
170
|
|
159
|
-
# Determine if the current node is a member of the 'suse' platform family
|
171
|
+
# Determine if the current node is a member of the 'suse' platform family (openSUSE, SLES, and SLED).
|
160
172
|
#
|
161
|
-
# @param [Chef::Node] node
|
173
|
+
# @param [Chef::Node] node the node to check
|
174
|
+
# @since 15.5
|
162
175
|
#
|
163
176
|
# @return [Boolean]
|
164
177
|
#
|
@@ -168,7 +181,8 @@ module ChefUtils
|
|
168
181
|
|
169
182
|
# Determine if the current node is a member of the 'gentoo' platform family.
|
170
183
|
#
|
171
|
-
# @param [Chef::Node] node
|
184
|
+
# @param [Chef::Node] node the node to check
|
185
|
+
# @since 15.5
|
172
186
|
#
|
173
187
|
# @return [Boolean]
|
174
188
|
#
|
@@ -178,7 +192,8 @@ module ChefUtils
|
|
178
192
|
|
179
193
|
# Determine if the current node is a member of the 'freebsd' platform family.
|
180
194
|
#
|
181
|
-
# @param [Chef::Node] node
|
195
|
+
# @param [Chef::Node] node the node to check
|
196
|
+
# @since 15.5
|
182
197
|
#
|
183
198
|
# @return [Boolean]
|
184
199
|
#
|
@@ -188,7 +203,8 @@ module ChefUtils
|
|
188
203
|
|
189
204
|
# Determine if the current node is a member of the 'openbsd' platform family.
|
190
205
|
#
|
191
|
-
# @param [Chef::Node] node
|
206
|
+
# @param [Chef::Node] node the node to check
|
207
|
+
# @since 15.5
|
192
208
|
#
|
193
209
|
# @return [Boolean]
|
194
210
|
#
|
@@ -198,7 +214,8 @@ module ChefUtils
|
|
198
214
|
|
199
215
|
# Determine if the current node is a member of the 'netbsd' platform family.
|
200
216
|
#
|
201
|
-
# @param [Chef::Node] node
|
217
|
+
# @param [Chef::Node] node the node to check
|
218
|
+
# @since 15.5
|
202
219
|
#
|
203
220
|
# @return [Boolean]
|
204
221
|
#
|
@@ -208,7 +225,8 @@ module ChefUtils
|
|
208
225
|
|
209
226
|
# Determine if the current node is a member of the 'dragonflybsd' platform family.
|
210
227
|
#
|
211
|
-
# @param [Chef::Node] node
|
228
|
+
# @param [Chef::Node] node the node to check
|
229
|
+
# @since 15.5
|
212
230
|
#
|
213
231
|
# @return [Boolean]
|
214
232
|
#
|
@@ -218,7 +236,8 @@ module ChefUtils
|
|
218
236
|
|
219
237
|
# Determine if the current node is a member of the 'windows' platform family.
|
220
238
|
#
|
221
|
-
# @param [Chef::Node] node
|
239
|
+
# @param [Chef::Node] node the node to check
|
240
|
+
# @since 15.5
|
222
241
|
#
|
223
242
|
# @return [Boolean]
|
224
243
|
#
|
@@ -236,8 +255,10 @@ module ChefUtils
|
|
236
255
|
node ? node["platform_family"] == "windows" : windows_ruby?
|
237
256
|
end
|
238
257
|
|
239
|
-
# Determine if the
|
240
|
-
# this behavior, so this is useful for code which can never be parsed on a non-
|
258
|
+
# Determine if the Ruby VM is currently running on a Windows node (ChefSpec can never stub
|
259
|
+
# this behavior, so this is useful for code which can never be parsed on a non-Windows box).
|
260
|
+
#
|
261
|
+
# @since 15.5
|
241
262
|
#
|
242
263
|
# @return [Boolean]
|
243
264
|
#
|
@@ -257,7 +278,8 @@ module ChefUtils
|
|
257
278
|
# less useful since in no way can AIX trace its lineage back to old redhat distros. This is most useful for
|
258
279
|
# "smells like redhat, including SuSE".
|
259
280
|
#
|
260
|
-
# @param [Chef::Node] node
|
281
|
+
# @param [Chef::Node] node the node to check
|
282
|
+
# @since 15.5
|
261
283
|
#
|
262
284
|
# @return [Boolean]
|
263
285
|
#
|
@@ -265,11 +287,12 @@ module ChefUtils
|
|
265
287
|
fedora_derived?(node) || node["platform_family"] == "suse"
|
266
288
|
end
|
267
289
|
|
268
|
-
# RPM-based distros which are not SuSE and are very loosely similar to fedora, using yum or dnf.
|
269
|
-
# lineage of the distro should have forked off from old redhat fedora distros at some point.
|
270
|
-
# fedora and amazon.
|
290
|
+
# RPM-based distros which are not SuSE and are very loosely similar to fedora, using yum or dnf. The historical
|
291
|
+
# lineage of the distro should have forked off from old redhat fedora distros at some point. Currently rhel,
|
292
|
+
# fedora and amazon. This is most useful for "smells like redhat, but isn't SuSE".
|
271
293
|
#
|
272
|
-
# @param [Chef::Node] node
|
294
|
+
# @param [Chef::Node] node the node to check
|
295
|
+
# @since 15.5
|
273
296
|
#
|
274
297
|
# @return [Boolean]
|
275
298
|
#
|
@@ -277,10 +300,11 @@ module ChefUtils
|
|
277
300
|
redhat_based?(node) || node["platform_family"] == "amazon"
|
278
301
|
end
|
279
302
|
|
280
|
-
# RedHat distros -- fedora and rhel platform_families, nothing else.
|
281
|
-
# "
|
303
|
+
# RedHat distros -- fedora and rhel platform_families, nothing else. This is most likely not as useful as the
|
304
|
+
# "fedora_derived?" helper.
|
282
305
|
#
|
283
|
-
# @param [Chef::Node] node
|
306
|
+
# @param [Chef::Node] node the node to check
|
307
|
+
# @since 15.5
|
284
308
|
#
|
285
309
|
# @return [Boolean]
|
286
310
|
#
|
@@ -290,7 +314,8 @@ module ChefUtils
|
|
290
314
|
|
291
315
|
# All of the Solaris-lineage.
|
292
316
|
#
|
293
|
-
# @param [Chef::Node] node
|
317
|
+
# @param [Chef::Node] node the node to check
|
318
|
+
# @since 15.5
|
294
319
|
#
|
295
320
|
# @return [Boolean]
|
296
321
|
#
|
@@ -300,9 +325,10 @@ module ChefUtils
|
|
300
325
|
|
301
326
|
# All of the BSD-lineage.
|
302
327
|
#
|
303
|
-
# Note that
|
328
|
+
# Note that macOS is not included since macOS deviates so significantly from BSD that including it would not be useful.
|
304
329
|
#
|
305
|
-
# @param [Chef::Node] node
|
330
|
+
# @param [Chef::Node] node the node to check
|
331
|
+
# @since 15.5
|
306
332
|
#
|
307
333
|
# @return [Boolean]
|
308
334
|
#
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -28,6 +28,8 @@ module ChefUtils
|
|
28
28
|
|
29
29
|
# Returns if debian's old rc.d manager is installed (not necessarily the primary init system).
|
30
30
|
#
|
31
|
+
# @since 15.5
|
32
|
+
#
|
31
33
|
# @return [Boolean]
|
32
34
|
#
|
33
35
|
def debianrcd?
|
@@ -36,6 +38,8 @@ module ChefUtils
|
|
36
38
|
|
37
39
|
# Returns if debian's old invoke rc.d manager is installed (not necessarily the primary init system).
|
38
40
|
#
|
41
|
+
# @since 15.5
|
42
|
+
#
|
39
43
|
# @return [Boolean]
|
40
44
|
#
|
41
45
|
def invokercd?
|
@@ -44,6 +48,8 @@ module ChefUtils
|
|
44
48
|
|
45
49
|
# Returns if upstart is installed (not necessarily the primary init system).
|
46
50
|
#
|
51
|
+
# @since 15.5
|
52
|
+
#
|
47
53
|
# @return [Boolean]
|
48
54
|
#
|
49
55
|
def upstart?
|
@@ -52,6 +58,8 @@ module ChefUtils
|
|
52
58
|
|
53
59
|
# Returns if insserv is installed (not necessarily the primary init system).
|
54
60
|
#
|
61
|
+
# @since 15.5
|
62
|
+
#
|
55
63
|
# @return [Boolean]
|
56
64
|
#
|
57
65
|
def insserv?
|
@@ -60,6 +68,8 @@ module ChefUtils
|
|
60
68
|
|
61
69
|
# Returns if redhat's init system is installed (not necessarily the primary init system).
|
62
70
|
#
|
71
|
+
# @since 15.5
|
72
|
+
#
|
63
73
|
# @return [Boolean]
|
64
74
|
#
|
65
75
|
def redhatrcd?
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -161,7 +161,7 @@ module ChefUtils
|
|
161
161
|
node.dig("virtualization", "system") == "openvz" && node.dig("virtualization", "role") == "host"
|
162
162
|
end
|
163
163
|
|
164
|
-
# Determine if the current node is running under any
|
164
|
+
# Determine if the current node is running under any virtualization environment
|
165
165
|
#
|
166
166
|
# @param [Chef::Node] node
|
167
167
|
# @since 15.8
|
data/lib/chef-utils/dsl/which.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -25,7 +25,7 @@ module ChefUtils
|
|
25
25
|
# Lookup an executable through the systems search PATH. Allows specifying an array
|
26
26
|
# of executables to look for. The first executable that is found, along any path entry,
|
27
27
|
# will be the preferred one and returned first. The extra_path will override any default
|
28
|
-
# extra_paths which are added (
|
28
|
+
# extra_paths which are added (allowing the user to pass an empty array to remove them).
|
29
29
|
#
|
30
30
|
# When passed a block the block will be called with the full pathname of any executables
|
31
31
|
# which are found, and the block should return truthy or falsey values to further filter
|
@@ -34,7 +34,7 @@ module ChefUtils
|
|
34
34
|
# This is syntactic sugar for `where(...).first`
|
35
35
|
#
|
36
36
|
# This helper can be used in target mode in chef or with train using the appropriate
|
37
|
-
# wiring
|
37
|
+
# wiring externally.
|
38
38
|
#
|
39
39
|
# @example Find the most appropriate python executable, searching through the system PATH
|
40
40
|
# plus additionally the "/usr/libexec" directory, which has the dnf libraries
|
@@ -55,14 +55,14 @@ module ChefUtils
|
|
55
55
|
# Lookup all the instances of an an executable that can be found through the systems search PATH.
|
56
56
|
# Allows specifying an array of executables to look for. All the instances of the first executable
|
57
57
|
# that is found will be returned first. The extra_path will override any default extra_paths
|
58
|
-
# which are added (
|
58
|
+
# which are added (allowing the user to pass an empty array to remove them).
|
59
59
|
#
|
60
60
|
# When passed a block the block will be called with the full pathname of any executables
|
61
61
|
# which are found, and the block should return truthy or falsey values to further filter
|
62
62
|
# the executable based on arbitrary criteria.
|
63
63
|
#
|
64
64
|
# This helper can be used in target mode in chef or with train using the appropriate
|
65
|
-
# wiring
|
65
|
+
# wiring externally.
|
66
66
|
#
|
67
67
|
# @example Find all the python executables, searching through the system PATH plus additionally
|
68
68
|
# the "/usr/libexec" directory, which have the dnf libraries installed and available.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -26,7 +26,8 @@ module ChefUtils
|
|
26
26
|
|
27
27
|
# Determine if the current node is Windows Server Core.
|
28
28
|
#
|
29
|
-
# @param [Chef::Node] node
|
29
|
+
# @param [Chef::Node] node the node to check
|
30
|
+
# @since 15.7
|
30
31
|
#
|
31
32
|
# @return [Boolean]
|
32
33
|
#
|
@@ -34,9 +35,10 @@ module ChefUtils
|
|
34
35
|
node["kernel"]["server_core"] == true
|
35
36
|
end
|
36
37
|
|
37
|
-
# Determine if the current node is Windows Workstation
|
38
|
+
# Determine if the current node is Windows Workstation.
|
38
39
|
#
|
39
|
-
# @param [Chef::Node] node
|
40
|
+
# @param [Chef::Node] node the node to check
|
41
|
+
# @since 15.7
|
40
42
|
#
|
41
43
|
# @return [Boolean]
|
42
44
|
#
|
@@ -44,9 +46,10 @@ module ChefUtils
|
|
44
46
|
node["kernel"]["product_type"] == "Workstation"
|
45
47
|
end
|
46
48
|
|
47
|
-
# Determine if the current node is Windows Server
|
49
|
+
# Determine if the current node is Windows Server.
|
48
50
|
#
|
49
|
-
# @param [Chef::Node] node
|
51
|
+
# @param [Chef::Node] node the node to check
|
52
|
+
# @since 15.7
|
50
53
|
#
|
51
54
|
# @return [Boolean]
|
52
55
|
#
|
@@ -56,7 +59,8 @@ module ChefUtils
|
|
56
59
|
|
57
60
|
# 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.
|
58
61
|
#
|
59
|
-
# @param [Chef::Node] node
|
62
|
+
# @param [Chef::Node] node the node to check
|
63
|
+
# @since 15.8
|
60
64
|
#
|
61
65
|
# @return [ChefUtils::VersionString]
|
62
66
|
#
|
@@ -64,9 +68,10 @@ module ChefUtils
|
|
64
68
|
ChefUtils::VersionString.new(node["os_version"])
|
65
69
|
end
|
66
70
|
|
67
|
-
# Determine the installed version of PowerShell
|
71
|
+
# Determine the installed version of PowerShell.
|
68
72
|
#
|
69
|
-
# @param [Chef::Node] node
|
73
|
+
# @param [Chef::Node] node the node to check
|
74
|
+
# @since 15.8
|
70
75
|
#
|
71
76
|
# @return [ChefUtils::VersionString]
|
72
77
|
#
|