chef-utils 16.10.17 → 17.10.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/Rakefile +15 -15
  4. data/chef-utils.gemspec +50 -46
  5. data/lib/chef-utils/dist.rb +151 -98
  6. data/lib/chef-utils/dsl/architecture.rb +150 -150
  7. data/lib/chef-utils/dsl/cloud.rb +155 -144
  8. data/lib/chef-utils/dsl/default_paths.rb +60 -60
  9. data/lib/chef-utils/dsl/introspection.rb +134 -123
  10. data/lib/chef-utils/dsl/os.rb +58 -58
  11. data/lib/chef-utils/dsl/path_sanity.rb +39 -39
  12. data/lib/chef-utils/dsl/platform.rb +387 -372
  13. data/lib/chef-utils/dsl/platform_family.rb +355 -344
  14. data/lib/chef-utils/dsl/platform_version.rb +41 -41
  15. data/lib/chef-utils/dsl/service.rb +112 -112
  16. data/lib/chef-utils/dsl/train_helpers.rb +87 -87
  17. data/lib/chef-utils/dsl/virtualization.rb +272 -250
  18. data/lib/chef-utils/dsl/which.rb +123 -123
  19. data/lib/chef-utils/dsl/windows.rb +86 -86
  20. data/lib/chef-utils/internal.rb +114 -114
  21. data/lib/chef-utils/mash.rb +263 -240
  22. data/lib/chef-utils/parallel_map.rb +131 -0
  23. data/lib/chef-utils/version.rb +20 -20
  24. data/lib/chef-utils/version_string.rb +160 -160
  25. data/lib/chef-utils.rb +53 -53
  26. data/spec/spec_helper.rb +100 -100
  27. data/spec/unit/dsl/architecture_spec.rb +151 -151
  28. data/spec/unit/dsl/cloud_spec.rb +93 -89
  29. data/spec/unit/dsl/dsl_spec.rb +34 -34
  30. data/spec/unit/dsl/introspection_spec.rb +201 -189
  31. data/spec/unit/dsl/os_spec.rb +175 -175
  32. data/spec/unit/dsl/path_sanity_spec.rb +86 -86
  33. data/spec/unit/dsl/platform_family_spec.rb +235 -223
  34. data/spec/unit/dsl/platform_spec.rb +252 -238
  35. data/spec/unit/dsl/service_spec.rb +117 -117
  36. data/spec/unit/dsl/virtualization_spec.rb +75 -75
  37. data/spec/unit/dsl/which_spec.rb +171 -171
  38. data/spec/unit/dsl/windows_spec.rb +84 -84
  39. data/spec/unit/mash_spec.rb +51 -51
  40. data/spec/unit/parallel_map_spec.rb +156 -0
  41. metadata +26 -10
@@ -1,372 +1,387 @@
1
- # frozen_string_literal: true
2
- #
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require_relative "../internal"
20
-
21
- module ChefUtils
22
- module DSL
23
- module Platform
24
- include Internal
25
-
26
- # NOTE: if you are adding new platform helpers they should all have the `_platform?` suffix.
27
- # DO NOT add new short aliases without the suffix (they will be deprecated in the future)
28
- # aliases here are mostly for backwards compatibility with chef-sugar and new ones are DISCOURAGED.
29
- # generally there should be one obviously correct way to do things.
30
-
31
- # Determine if the current node is linux mint.
32
- #
33
- # @param [Chef::Node] node the node to check
34
- # @since 15.5
35
- #
36
- # @return [Boolean]
37
- #
38
- def linuxmint_platform?(node = __getnode)
39
- node["platform"] == "linuxmint"
40
- end
41
- # chef-sugar backcompat method
42
- alias_method :mint?, :linuxmint_platform?
43
- # chef-sugar backcompat method
44
- alias_method :linux_mint?, :linuxmint_platform?
45
- # chef-sugar backcompat method
46
- alias_method :linuxmint?, :linuxmint_platform?
47
-
48
- # Determine if the current node is Ubuntu.
49
- #
50
- # @param [Chef::Node] node the node to check
51
- # @since 15.5
52
- #
53
- # @return [Boolean]
54
- #
55
- def ubuntu_platform?(node = __getnode)
56
- node["platform"] == "ubuntu"
57
- end
58
- # chef-sugar backcompat method
59
- alias_method :ubuntu?, :ubuntu_platform?
60
-
61
- # Determine if the current node is Raspbian.
62
- #
63
- # @param [Chef::Node] node the node to check
64
- # @since 15.5
65
- #
66
- # @return [Boolean]
67
- #
68
- def raspbian_platform?(node = __getnode)
69
- node["platform"] == "raspbian"
70
- end
71
- # chef-sugar backcompat method
72
- alias_method :raspbian?, :raspbian_platform?
73
-
74
- # Determine if the current node is Debian.
75
- #
76
- # @param [Chef::Node] node the node to check
77
- # @since 15.5
78
- #
79
- # @return [Boolean]
80
- #
81
- def debian_platform?(node = __getnode)
82
- node["platform"] == "debian"
83
- end
84
-
85
- # Determine if the current node is Amazon Linux.
86
- #
87
- # @param [Chef::Node] node the node to check
88
- # @since 15.5
89
- #
90
- # @return [Boolean]
91
- #
92
- def amazon_platform?(node = __getnode)
93
- node["platform"] == "amazon"
94
- end
95
-
96
- # Determine if the current node is Red Hat Enterprise Linux.
97
- #
98
- # @param [Chef::Node] node the node to check
99
- # @since 15.5
100
- #
101
- # @return [Boolean]
102
- #
103
- def redhat_platform?(node = __getnode)
104
- node["platform"] == "redhat"
105
- end
106
- # chef-sugar backcompat method
107
- alias_method :redhat_enterprise?, :redhat_platform?
108
- # chef-sugar backcompat method
109
- alias_method :redhat_enterprise_linux?, :redhat_platform?
110
- # chef-sugar backcompat method
111
- alias_method :redhat?, :redhat_platform?
112
-
113
- # Determine if the current node is CentOS.
114
- #
115
- # @param [Chef::Node] node the node to check
116
- # @since 15.5
117
- #
118
- # @return [Boolean]
119
- #
120
- def centos_platform?(node = __getnode)
121
- node["platform"] == "centos"
122
- end
123
- # chef-sugar backcompat method
124
- alias_method :centos?, :centos_platform?
125
-
126
- # Determine if the current node is Oracle Linux.
127
- #
128
- # @param [Chef::Node] node the node to check
129
- # @since 15.5
130
- #
131
- # @return [Boolean]
132
- #
133
- def oracle_platform?(node = __getnode)
134
- node["platform"] == "oracle"
135
- end
136
- # chef-sugar backcompat method
137
- alias_method :oracle_linux?, :oracle_platform?
138
- # chef-sugar backcompat method
139
- alias_method :oracle?, :oracle_platform?
140
-
141
- # Determine if the current node is Scientific Linux.
142
- #
143
- # @param [Chef::Node] node the node to check
144
- # @since 15.5
145
- #
146
- # @return [Boolean]
147
- #
148
- def scientific_platform?(node = __getnode)
149
- node["platform"] == "scientific"
150
- end
151
- # chef-sugar backcompat method
152
- alias_method :scientific_linux?, :scientific_platform?
153
- # chef-sugar backcompat method
154
- alias_method :scientific?, :scientific_platform?
155
-
156
- # Determine if the current node is ClearOS.
157
- #
158
- # @param [Chef::Node] node the node to check
159
- # @since 15.5
160
- #
161
- # @return [Boolean]
162
- #
163
- def clearos_platform?(node = __getnode)
164
- node["platform"] == "clearos"
165
- end
166
- # chef-sugar backcompat method
167
- alias_method :clearos?, :clearos_platform?
168
-
169
- # Determine if the current node is Fedora.
170
- #
171
- # @param [Chef::Node] node the node to check
172
- # @since 15.5
173
- #
174
- # @return [Boolean]
175
- #
176
- def fedora_platform?(node = __getnode)
177
- node["platform"] == "fedora"
178
- end
179
-
180
- # Determine if the current node is Arch Linux
181
- #
182
- # @param [Chef::Node] node the node to check
183
- # @since 15.5
184
- #
185
- # @return [Boolean]
186
- #
187
- def arch_platform?(node = __getnode)
188
- node["platform"] == "arch"
189
- end
190
-
191
- # Determine if the current node is Solaris2.
192
- #
193
- # @param [Chef::Node] node the node to check
194
- # @since 15.5
195
- #
196
- # @return [Boolean]
197
- #
198
- def solaris2_platform?(node = __getnode)
199
- node["platform"] == "solaris2"
200
- end
201
-
202
- # Determine if the current node is SmartOS.
203
- #
204
- # @param [Chef::Node] node the node to check
205
- # @since 15.5
206
- #
207
- # @return [Boolean]
208
- #
209
- def smartos_platform?(node = __getnode)
210
- node["platform"] == "smartos"
211
- end
212
-
213
- # Determine if the current node is OmniOS.
214
- #
215
- # @param [Chef::Node] node the node to check
216
- # @since 15.5
217
- #
218
- # @return [Boolean]
219
- #
220
- def omnios_platform?(node = __getnode)
221
- node["platform"] == "omnios"
222
- end
223
- # chef-sugar backcompat method
224
- alias_method :omnios?, :omnios_platform?
225
-
226
- # Determine if the current node is OpenIndiana.
227
- #
228
- # @param [Chef::Node] node the node to check
229
- # @since 15.5
230
- #
231
- # @return [Boolean]
232
- #
233
- def openindiana_platform?(node = __getnode)
234
- node["platform"] == "openindiana"
235
- end
236
- # chef-sugar backcompat method
237
- alias_method :openindiana?, :openindiana_platform?
238
-
239
- # Determine if the current node is AIX.
240
- #
241
- # @param [Chef::Node] node the node to check
242
- # @since 15.5
243
- #
244
- # @return [Boolean]
245
- #
246
- def aix_platform?(node = __getnode)
247
- node["platform"] == "aix"
248
- end
249
-
250
- # Determine if the current node is FreeBSD.
251
- #
252
- # @param [Chef::Node] node the node to check
253
- # @since 15.5
254
- #
255
- # @return [Boolean]
256
- #
257
- def freebsd_platform?(node = __getnode)
258
- node["platform"] == "freebsd"
259
- end
260
-
261
- # Determine if the current node is OpenBSD.
262
- #
263
- # @param [Chef::Node] node the node to check
264
- # @since 15.5
265
- #
266
- # @return [Boolean]
267
- #
268
- def openbsd_platform?(node = __getnode)
269
- node["platform"] == "openbsd"
270
- end
271
-
272
- # Determine if the current node is NetBSD.
273
- #
274
- # @param [Chef::Node] node the node to check
275
- # @since 15.5
276
- #
277
- # @return [Boolean]
278
- #
279
- def netbsd_platform?(node = __getnode)
280
- node["platform"] == "netbsd"
281
- end
282
-
283
- # Determine if the current node is DragonFly BSD.
284
- #
285
- # @param [Chef::Node] node the node to check
286
- # @since 15.5
287
- #
288
- # @return [Boolean]
289
- #
290
- def dragonfly_platform?(node = __getnode)
291
- node["platform"] == "dragonfly"
292
- end
293
-
294
- # Determine if the current node is macOS.
295
- #
296
- # @param [Chef::Node] node the node to check
297
- # @since 15.5
298
- #
299
- # @return [Boolean]
300
- #
301
- def macos_platform?(node = __getnode)
302
- node["platform"] == "mac_os_x"
303
- end
304
- # chef-sugar backcompat method
305
- alias_method :mac_os_x_platform?, :macos_platform?
306
-
307
- # Determine if the current node is Gentoo.
308
- #
309
- # @param [Chef::Node] node the node to check
310
- # @since 15.5
311
- #
312
- # @return [Boolean]
313
- #
314
- def gentoo_platform?(node = __getnode)
315
- node["platform"] == "gentoo"
316
- end
317
-
318
- # Determine if the current node is Slackware.
319
- #
320
- # @param [Chef::Node] node the node to check
321
- # @since 15.5
322
- #
323
- # @return [Boolean]
324
- #
325
- def slackware_platform?(node = __getnode)
326
- node["platform"] == "slackware"
327
- end
328
-
329
- # Determine if the current node is SuSE.
330
- #
331
- # @param [Chef::Node] node the node to check
332
- # @since 15.5
333
- #
334
- # @return [Boolean]
335
- #
336
- def suse_platform?(node = __getnode)
337
- node["platform"] == "suse"
338
- end
339
-
340
- # Determine if the current node is openSUSE.
341
- #
342
- # @param [Chef::Node] node the node to check
343
- # @since 15.5
344
- #
345
- # @return [Boolean]
346
- #
347
- def opensuse_platform?(node = __getnode)
348
- node["platform"] == "opensuse" || node["platform"] == "opensuseleap"
349
- end
350
- # chef-sugar backcompat method
351
- alias_method :opensuse?, :opensuse_platform?
352
- # chef-sugar backcompat method
353
- alias_method :opensuseleap_platform?, :opensuse_platform?
354
- # chef-sugar backcompat method
355
- alias_method :leap_platform?, :opensuse_platform?
356
- # NOTE: to anyone adding :tumbleweed_platform? - :[opensuse]leap_platform? should be false on tumbleweed, :opensuse[_platform]? should be true
357
-
358
- # Determine if the current node is Windows.
359
- #
360
- # @param [Chef::Node] node the node to check
361
- # @since 15.5
362
- #
363
- # @return [Boolean]
364
- #
365
- def windows_platform?(node = __getnode)
366
- node["platform"] == "windows"
367
- end
368
-
369
- extend self
370
- end
371
- end
372
- end
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require_relative "../internal"
20
+
21
+ module ChefUtils
22
+ module DSL
23
+ module Platform
24
+ include Internal
25
+
26
+ # NOTE: if you are adding new platform helpers they should all have the `_platform?` suffix.
27
+ # DO NOT add new short aliases without the suffix (they will be deprecated in the future)
28
+ # aliases here are mostly for backwards compatibility with chef-sugar and new ones are DISCOURAGED.
29
+ # generally there should be one obviously correct way to do things.
30
+
31
+ # Determine if the current node is linux mint.
32
+ #
33
+ # @param [Chef::Node] node the node to check
34
+ # @since 15.5
35
+ #
36
+ # @return [Boolean]
37
+ #
38
+ def linuxmint_platform?(node = __getnode)
39
+ node["platform"] == "linuxmint"
40
+ end
41
+ # chef-sugar backcompat method
42
+ alias_method :mint?, :linuxmint_platform?
43
+ # chef-sugar backcompat method
44
+ alias_method :linux_mint?, :linuxmint_platform?
45
+ # chef-sugar backcompat method
46
+ alias_method :linuxmint?, :linuxmint_platform?
47
+
48
+ # Determine if the current node is Ubuntu.
49
+ #
50
+ # @param [Chef::Node] node the node to check
51
+ # @since 15.5
52
+ #
53
+ # @return [Boolean]
54
+ #
55
+ def ubuntu_platform?(node = __getnode)
56
+ node["platform"] == "ubuntu"
57
+ end
58
+ # chef-sugar backcompat method
59
+ alias_method :ubuntu?, :ubuntu_platform?
60
+
61
+ # Determine if the current node is Raspbian.
62
+ #
63
+ # @param [Chef::Node] node the node to check
64
+ # @since 15.5
65
+ #
66
+ # @return [Boolean]
67
+ #
68
+ def raspbian_platform?(node = __getnode)
69
+ node["platform"] == "raspbian"
70
+ end
71
+ # chef-sugar backcompat method
72
+ alias_method :raspbian?, :raspbian_platform?
73
+
74
+ # Determine if the current node is Debian.
75
+ #
76
+ # @param [Chef::Node] node the node to check
77
+ # @since 15.5
78
+ #
79
+ # @return [Boolean]
80
+ #
81
+ def debian_platform?(node = __getnode)
82
+ node["platform"] == "debian"
83
+ end
84
+
85
+ # Determine if the current node is Amazon Linux.
86
+ #
87
+ # @param [Chef::Node] node the node to check
88
+ # @since 15.5
89
+ #
90
+ # @return [Boolean]
91
+ #
92
+ def amazon_platform?(node = __getnode)
93
+ node["platform"] == "amazon"
94
+ end
95
+
96
+ # Determine if the current node is Red Hat Enterprise Linux.
97
+ #
98
+ # @param [Chef::Node] node the node to check
99
+ # @since 15.5
100
+ #
101
+ # @return [Boolean]
102
+ #
103
+ def redhat_platform?(node = __getnode)
104
+ node["platform"] == "redhat"
105
+ end
106
+ # chef-sugar backcompat method
107
+ alias_method :redhat_enterprise?, :redhat_platform?
108
+ # chef-sugar backcompat method
109
+ alias_method :redhat_enterprise_linux?, :redhat_platform?
110
+ # chef-sugar backcompat method
111
+ alias_method :redhat?, :redhat_platform?
112
+
113
+ # Determine if the current node is CentOS.
114
+ #
115
+ # @param [Chef::Node] node the node to check
116
+ # @since 15.5
117
+ #
118
+ # @return [Boolean]
119
+ #
120
+ def centos_platform?(node = __getnode)
121
+ node["platform"] == "centos"
122
+ end
123
+ # chef-sugar backcompat method
124
+ alias_method :centos?, :centos_platform?
125
+
126
+ # Determine if the current node is CentOS Stream.
127
+ #
128
+ # @param [Chef::Node] node the node to check
129
+ # @since 17.0
130
+ #
131
+ # @return [Boolean]
132
+ #
133
+ def centos_stream_platform?(node = __getnode)
134
+ if node["os_release"]
135
+ node.dig("os_release", "name") == "CentOS Stream"
136
+ else
137
+ node.dig("lsb", "id") == "CentOSStream"
138
+ end
139
+ end
140
+
141
+ # Determine if the current node is Oracle Linux.
142
+ #
143
+ # @param [Chef::Node] node the node to check
144
+ # @since 15.5
145
+ #
146
+ # @return [Boolean]
147
+ #
148
+ def oracle_platform?(node = __getnode)
149
+ node["platform"] == "oracle"
150
+ end
151
+ # chef-sugar backcompat method
152
+ alias_method :oracle_linux?, :oracle_platform?
153
+ # chef-sugar backcompat method
154
+ alias_method :oracle?, :oracle_platform?
155
+
156
+ # Determine if the current node is Scientific Linux.
157
+ #
158
+ # @param [Chef::Node] node the node to check
159
+ # @since 15.5
160
+ #
161
+ # @return [Boolean]
162
+ #
163
+ def scientific_platform?(node = __getnode)
164
+ node["platform"] == "scientific"
165
+ end
166
+ # chef-sugar backcompat method
167
+ alias_method :scientific_linux?, :scientific_platform?
168
+ # chef-sugar backcompat method
169
+ alias_method :scientific?, :scientific_platform?
170
+
171
+ # Determine if the current node is ClearOS.
172
+ #
173
+ # @param [Chef::Node] node the node to check
174
+ # @since 15.5
175
+ #
176
+ # @return [Boolean]
177
+ #
178
+ def clearos_platform?(node = __getnode)
179
+ node["platform"] == "clearos"
180
+ end
181
+ # chef-sugar backcompat method
182
+ alias_method :clearos?, :clearos_platform?
183
+
184
+ # Determine if the current node is Fedora.
185
+ #
186
+ # @param [Chef::Node] node the node to check
187
+ # @since 15.5
188
+ #
189
+ # @return [Boolean]
190
+ #
191
+ def fedora_platform?(node = __getnode)
192
+ node["platform"] == "fedora"
193
+ end
194
+
195
+ # Determine if the current node is Arch Linux
196
+ #
197
+ # @param [Chef::Node] node the node to check
198
+ # @since 15.5
199
+ #
200
+ # @return [Boolean]
201
+ #
202
+ def arch_platform?(node = __getnode)
203
+ node["platform"] == "arch"
204
+ end
205
+
206
+ # Determine if the current node is Solaris2.
207
+ #
208
+ # @param [Chef::Node] node the node to check
209
+ # @since 15.5
210
+ #
211
+ # @return [Boolean]
212
+ #
213
+ def solaris2_platform?(node = __getnode)
214
+ node["platform"] == "solaris2"
215
+ end
216
+
217
+ # Determine if the current node is SmartOS.
218
+ #
219
+ # @param [Chef::Node] node the node to check
220
+ # @since 15.5
221
+ #
222
+ # @return [Boolean]
223
+ #
224
+ def smartos_platform?(node = __getnode)
225
+ node["platform"] == "smartos"
226
+ end
227
+
228
+ # Determine if the current node is OmniOS.
229
+ #
230
+ # @param [Chef::Node] node the node to check
231
+ # @since 15.5
232
+ #
233
+ # @return [Boolean]
234
+ #
235
+ def omnios_platform?(node = __getnode)
236
+ node["platform"] == "omnios"
237
+ end
238
+ # chef-sugar backcompat method
239
+ alias_method :omnios?, :omnios_platform?
240
+
241
+ # Determine if the current node is OpenIndiana.
242
+ #
243
+ # @param [Chef::Node] node the node to check
244
+ # @since 15.5
245
+ #
246
+ # @return [Boolean]
247
+ #
248
+ def openindiana_platform?(node = __getnode)
249
+ node["platform"] == "openindiana"
250
+ end
251
+ # chef-sugar backcompat method
252
+ alias_method :openindiana?, :openindiana_platform?
253
+
254
+ # Determine if the current node is AIX.
255
+ #
256
+ # @param [Chef::Node] node the node to check
257
+ # @since 15.5
258
+ #
259
+ # @return [Boolean]
260
+ #
261
+ def aix_platform?(node = __getnode)
262
+ node["platform"] == "aix"
263
+ end
264
+
265
+ # Determine if the current node is FreeBSD.
266
+ #
267
+ # @param [Chef::Node] node the node to check
268
+ # @since 15.5
269
+ #
270
+ # @return [Boolean]
271
+ #
272
+ def freebsd_platform?(node = __getnode)
273
+ node["platform"] == "freebsd"
274
+ end
275
+
276
+ # Determine if the current node is OpenBSD.
277
+ #
278
+ # @param [Chef::Node] node the node to check
279
+ # @since 15.5
280
+ #
281
+ # @return [Boolean]
282
+ #
283
+ def openbsd_platform?(node = __getnode)
284
+ node["platform"] == "openbsd"
285
+ end
286
+
287
+ # Determine if the current node is NetBSD.
288
+ #
289
+ # @param [Chef::Node] node the node to check
290
+ # @since 15.5
291
+ #
292
+ # @return [Boolean]
293
+ #
294
+ def netbsd_platform?(node = __getnode)
295
+ node["platform"] == "netbsd"
296
+ end
297
+
298
+ # Determine if the current node is DragonFly BSD.
299
+ #
300
+ # @param [Chef::Node] node the node to check
301
+ # @since 15.5
302
+ #
303
+ # @return [Boolean]
304
+ #
305
+ def dragonfly_platform?(node = __getnode)
306
+ node["platform"] == "dragonfly"
307
+ end
308
+
309
+ # Determine if the current node is macOS.
310
+ #
311
+ # @param [Chef::Node] node the node to check
312
+ # @since 15.5
313
+ #
314
+ # @return [Boolean]
315
+ #
316
+ def macos_platform?(node = __getnode)
317
+ node["platform"] == "mac_os_x"
318
+ end
319
+ # chef-sugar backcompat method
320
+ alias_method :mac_os_x_platform?, :macos_platform?
321
+
322
+ # Determine if the current node is Gentoo.
323
+ #
324
+ # @param [Chef::Node] node the node to check
325
+ # @since 15.5
326
+ #
327
+ # @return [Boolean]
328
+ #
329
+ def gentoo_platform?(node = __getnode)
330
+ node["platform"] == "gentoo"
331
+ end
332
+
333
+ # Determine if the current node is Slackware.
334
+ #
335
+ # @param [Chef::Node] node the node to check
336
+ # @since 15.5
337
+ #
338
+ # @return [Boolean]
339
+ #
340
+ def slackware_platform?(node = __getnode)
341
+ node["platform"] == "slackware"
342
+ end
343
+
344
+ # Determine if the current node is SuSE.
345
+ #
346
+ # @param [Chef::Node] node the node to check
347
+ # @since 15.5
348
+ #
349
+ # @return [Boolean]
350
+ #
351
+ def suse_platform?(node = __getnode)
352
+ node["platform"] == "suse"
353
+ end
354
+
355
+ # Determine if the current node is openSUSE.
356
+ #
357
+ # @param [Chef::Node] node the node to check
358
+ # @since 15.5
359
+ #
360
+ # @return [Boolean]
361
+ #
362
+ def opensuse_platform?(node = __getnode)
363
+ node["platform"] == "opensuse" || node["platform"] == "opensuseleap"
364
+ end
365
+ # chef-sugar backcompat method
366
+ alias_method :opensuse?, :opensuse_platform?
367
+ # chef-sugar backcompat method
368
+ alias_method :opensuseleap_platform?, :opensuse_platform?
369
+ # chef-sugar backcompat method
370
+ alias_method :leap_platform?, :opensuse_platform?
371
+ # NOTE: to anyone adding :tumbleweed_platform? - :[opensuse]leap_platform? should be false on tumbleweed, :opensuse[_platform]? should be true
372
+
373
+ # Determine if the current node is Windows.
374
+ #
375
+ # @param [Chef::Node] node the node to check
376
+ # @since 15.5
377
+ #
378
+ # @return [Boolean]
379
+ #
380
+ def windows_platform?(node = __getnode)
381
+ node["platform"] == "windows"
382
+ end
383
+
384
+ extend self
385
+ end
386
+ end
387
+ end