chef-sugar 5.0.1 → 5.1.8
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/sugar/architecture.rb +137 -132
- data/lib/chef/sugar/deprecation.rb +45 -0
- data/lib/chef/sugar/docker.rb +17 -12
- data/lib/chef/sugar/kitchen.rb +17 -12
- data/lib/chef/sugar/node.rb +6 -0
- data/lib/chef/sugar/platform.rb +169 -165
- data/lib/chef/sugar/platform_family.rb +142 -137
- data/lib/chef/sugar/shell.rb +5 -1
- data/lib/chef/sugar/version.rb +1 -1
- data/lib/chef/sugar/virtualization.rb +1 -1
- metadata +7 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227f7d0ee3fe7a7f8c4dd30ca3ae140eeeee3dfcbde7df0e59a3f9fdc8119297
|
4
|
+
data.tar.gz: 29ce42de49a7b7f0ef5a012e99130b0eec87df6aca9cf477ef783905613264de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a63872706b818c738bb04d7c7f464b346a4c9de718b2de357c019b7a74df271c3d5c53bd25ecc3afe693f0345ad0ffd4cb60443039a2220ae163db3dd2bcc6c
|
7
|
+
data.tar.gz: 9eca96a8c964d20c87b52c0a1e01d759c8154e8e0b9075008c57880aad4ffea9f21555158003e30d08299af9dab9338617487b7a8bb4e1388fe05b87b18ca828
|
@@ -19,153 +19,158 @@ class Chef
|
|
19
19
|
module Architecture
|
20
20
|
extend self
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
#
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
22
|
+
# these helpers have been moved to core-chef
|
23
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
24
|
+
#
|
25
|
+
# Determine if the current architecture is 64-bit
|
26
|
+
#
|
27
|
+
# @return [Boolean]
|
28
|
+
#
|
29
|
+
def _64_bit?(node)
|
30
|
+
%w(amd64 x86_64 ppc64 ppc64le s390x ia64 sparc64 aarch64 arch64 arm64 sun4v sun4u s390x)
|
31
|
+
.include?(node['kernel']['machine']) || ( node['kernel']['bits'] == '64' )
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Determine if the current architecture is 32-bit
|
36
|
+
#
|
37
|
+
# @todo Make this more than "not 64-bit"
|
38
|
+
#
|
39
|
+
# @return [Boolean]
|
40
|
+
#
|
41
|
+
def _32_bit?(node)
|
42
|
+
!_64_bit?(node)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Determine if the current architecture is i386
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
#
|
50
|
+
def i386?(node)
|
51
|
+
_32_bit?(node) && intel?(node)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Determine if the current architecture is Intel.
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
#
|
59
|
+
def intel?(node)
|
60
|
+
%w(i86pc i386 x86_64 amd64 i686)
|
61
|
+
.include?(node['kernel']['machine'])
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Determine if the current architecture is SPARC.
|
66
|
+
#
|
67
|
+
# @return [Boolean]
|
68
|
+
#
|
69
|
+
def sparc?(node)
|
70
|
+
%w(sun4u sun4v)
|
71
|
+
.include?(node['kernel']['machine'])
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Determine if the current architecture is Powerpc64 Big Endian
|
76
|
+
#
|
77
|
+
# @return [Boolean]
|
78
|
+
#
|
79
|
+
def ppc64?(node)
|
80
|
+
%w(ppc64)
|
81
|
+
.include?(node['kernel']['machine'])
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Determine if the current architecture is Powerpc64 Little Endian
|
86
|
+
#
|
87
|
+
# @return [Boolean]
|
88
|
+
#
|
89
|
+
def ppc64le?(node)
|
90
|
+
%w(ppc64le)
|
91
|
+
.include?(node['kernel']['machine'])
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Determine if the current architecture is PowerPC
|
96
|
+
#
|
97
|
+
# @return [Boolean]
|
98
|
+
#
|
99
|
+
def powerpc?(node)
|
100
|
+
%w(powerpc)
|
101
|
+
.include?(node['kernel']['machine'])
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# Determine if the current architecture is ARM with Hard Float
|
106
|
+
#
|
107
|
+
# @return [Boolean]
|
108
|
+
#
|
109
|
+
def armhf?(node)
|
110
|
+
# Add more arm variants as needed here
|
111
|
+
%w(armv6l armv7l)
|
112
|
+
.include?(node['kernel']['machine'])
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# Determine if the current architecture is AArch64
|
117
|
+
#
|
118
|
+
# @return [Boolean]
|
119
|
+
#
|
120
|
+
def aarch64?(node)
|
121
|
+
# Add more arm variants as needed here
|
122
|
+
%w(aarch64)
|
123
|
+
.include?(node['kernel']['machine'])
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Determine if the current architecture is s390x
|
128
|
+
#
|
129
|
+
# @return [Boolean]
|
130
|
+
#
|
131
|
+
def s390x?(node)
|
132
|
+
%w(s390x)
|
133
|
+
.include?(node['kernel']['machine'])
|
134
|
+
end
|
132
135
|
end
|
133
136
|
end
|
134
137
|
|
135
138
|
module DSL
|
136
|
-
|
137
|
-
|
139
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
140
|
+
# @see Chef::Sugar::Architecture#_64_bit?
|
141
|
+
def _64_bit?; Chef::Sugar::Architecture._64_bit?(node); end
|
138
142
|
|
139
|
-
|
140
|
-
|
143
|
+
# @see Chef::Sugar::Architecture#_32_bit?
|
144
|
+
def _32_bit?; Chef::Sugar::Architecture._32_bit?(node); end
|
141
145
|
|
142
|
-
|
143
|
-
|
146
|
+
# @see Chef::Sugar::Architecture#intel?
|
147
|
+
def i386?; Chef::Sugar::Architecture.i386?(node); end
|
144
148
|
|
145
|
-
|
146
|
-
|
149
|
+
# @see Chef::Sugar::Architecture#intel?
|
150
|
+
def intel?; Chef::Sugar::Architecture.intel?(node); end
|
147
151
|
|
148
|
-
|
149
|
-
|
152
|
+
# @see Chef::Sugar::Architecture#sparc?
|
153
|
+
def sparc?; Chef::Sugar::Architecture.sparc?(node); end
|
150
154
|
|
151
|
-
|
152
|
-
|
155
|
+
# @see Chef::Sugar::Architecture#ppc64?
|
156
|
+
def ppc64?; Chef::Sugar::Architecture.ppc64?(node); end
|
153
157
|
|
154
|
-
|
155
|
-
|
158
|
+
# @see Chef::Sugar::Architecture#ppc64le?
|
159
|
+
def ppc64le?; Chef::Sugar::Architecture.ppc64le?(node); end
|
156
160
|
|
157
|
-
|
158
|
-
|
161
|
+
# @see Chef::Sugar::Architecture#powerpc?
|
162
|
+
def powerpc?; Chef::Sugar::Architecture.powerpc?(node); end
|
159
163
|
|
160
|
-
|
161
|
-
|
164
|
+
# @see Chef::Sugar::Architecture#arm?
|
165
|
+
def armhf?; Chef::Sugar::Architecture.armhf?(node); end
|
162
166
|
|
163
|
-
|
164
|
-
|
167
|
+
# @see Chef::Sugar::Architecture#aarch64?
|
168
|
+
def aarch64?; Chef::Sugar::Architecture.aarch64?(node); end
|
165
169
|
|
166
|
-
|
167
|
-
|
170
|
+
# @see Chef::Sugar::Architecture#s390x?
|
171
|
+
def s390x?; Chef::Sugar::Architecture.s390x?(node); end
|
168
172
|
|
173
|
+
end
|
169
174
|
end
|
170
175
|
end
|
171
176
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
if defined?(Chef::Deprecated::Base)
|
16
|
+
class Chef
|
17
|
+
class Deprecated
|
18
|
+
class ChefSugar < Base
|
19
|
+
def id
|
20
|
+
28
|
21
|
+
end
|
22
|
+
def target
|
23
|
+
"chef_sugar.html"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Chef
|
31
|
+
module Sugar
|
32
|
+
module Deprecation
|
33
|
+
if defined?(Chef::Deprecated::Base)
|
34
|
+
def deprecated(message)
|
35
|
+
Chef.deprecated(:chef_sugar, message)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
def deprecated(message)
|
39
|
+
Chef::Log.warn(message)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
extend self
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/chef/sugar/docker.rb
CHANGED
@@ -19,22 +19,27 @@ class Chef
|
|
19
19
|
module Docker
|
20
20
|
extend self
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
# these helpers have been moved to core chef
|
23
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
24
|
+
#
|
25
|
+
# Returns true if the current node is a docker container.
|
26
|
+
#
|
27
|
+
# @param [Chef::Node] node
|
28
|
+
# the node to check
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
#
|
32
|
+
def docker?(node)
|
33
|
+
File.exist?('/.dockerinit') || File.exist?('/.dockerenv')
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
module DSL
|
36
|
-
|
37
|
-
|
39
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
40
|
+
# @see Chef::Sugar::Docker#docker?
|
41
|
+
def docker?; Chef::Sugar::Docker.docker?(node); end
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
data/lib/chef/sugar/kitchen.rb
CHANGED
@@ -19,22 +19,27 @@ class Chef
|
|
19
19
|
module Kitchen
|
20
20
|
extend self
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
# these helpers have been moved to core-chef
|
23
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
24
|
+
#
|
25
|
+
# Returns true if the current node is provisioned by Test Kitchen.
|
26
|
+
#
|
27
|
+
# @param [Chef::Node] node
|
28
|
+
# the node to check
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
#
|
32
|
+
def kitchen?(node)
|
33
|
+
!ENV['TEST_KITCHEN'].nil?
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
38
|
module DSL
|
36
|
-
|
37
|
-
|
39
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
40
|
+
# @see Chef::Sugar::Kitchen#kitchen?
|
41
|
+
def kitchen?; Chef::Sugar::Kitchen.kitchen?(node); end
|
42
|
+
end
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
data/lib/chef/sugar/node.rb
CHANGED
@@ -14,6 +14,8 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require_relative "deprecation"
|
18
|
+
|
17
19
|
class Chef
|
18
20
|
class Node
|
19
21
|
class AttributeDoesNotExistError < StandardError
|
@@ -36,6 +38,7 @@ EOH
|
|
36
38
|
# @return [Boolean]
|
37
39
|
#
|
38
40
|
def in?(environment)
|
41
|
+
Chef::Sugar::Deprecation.deprecated "the chef-sugar node.in? method is deprecated"
|
39
42
|
environment === chef_environment
|
40
43
|
end
|
41
44
|
|
@@ -49,6 +52,7 @@ EOH
|
|
49
52
|
# @see [Node#deep_fetch!]
|
50
53
|
#
|
51
54
|
def deep_fetch(*keys)
|
55
|
+
Chef::Sugar::Deprecation.deprecated "the chef-sugar deep_fetch method is deprecated and should be replaced by node.read"
|
52
56
|
deep_fetch!(*keys)
|
53
57
|
rescue NoMethodError, AttributeDoesNotExistError
|
54
58
|
nil
|
@@ -71,6 +75,7 @@ EOH
|
|
71
75
|
# @return [Object]
|
72
76
|
#
|
73
77
|
def deep_fetch!(*keys)
|
78
|
+
Chef::Sugar::Deprecation.deprecated "the chef-sugar deep_fetch method is deprecated and should be replaced by node.read!"
|
74
79
|
keys.map!(&:to_s)
|
75
80
|
|
76
81
|
keys.inject(attributes.to_hash) do |hash, key|
|
@@ -133,6 +138,7 @@ EOH
|
|
133
138
|
# to prevent accidential method chaining if the block isn't closed
|
134
139
|
#
|
135
140
|
def namespace(*args, &block)
|
141
|
+
Chef::Sugar::Deprecation.deprecated "the chef-sugar attribute namespace setting is deprecated, please use traditional chef attribute notation"
|
136
142
|
@namespace_options = namespace_options.merge(args.last.is_a?(Hash) ? args.pop : {})
|
137
143
|
|
138
144
|
keys = args.map(&:to_s)
|
data/lib/chef/sugar/platform.rb
CHANGED
@@ -121,186 +121,190 @@ class Chef
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
#
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
124
|
+
# these helpers have been moved to core chef
|
125
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
126
|
+
#
|
127
|
+
# Determine if the current node is linux mint.
|
128
|
+
#
|
129
|
+
# @param [Chef::Node] node
|
130
|
+
#
|
131
|
+
# @return [Boolean]
|
132
|
+
#
|
133
|
+
def linux_mint?(node)
|
134
|
+
node['platform'] == 'linuxmint'
|
135
|
+
end
|
136
|
+
alias_method :mint?, :linux_mint?
|
135
137
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
138
|
+
#
|
139
|
+
# Determine if the current node is ubuntu.
|
140
|
+
#
|
141
|
+
# @param [Chef::Node] node
|
142
|
+
#
|
143
|
+
# @return [Boolean]
|
144
|
+
#
|
145
|
+
def ubuntu?(node)
|
146
|
+
node['platform'] == 'ubuntu'
|
147
|
+
end
|
146
148
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
#
|
150
|
+
# Determine if the current node is debian (platform, not platform_family).
|
151
|
+
#
|
152
|
+
# @param [Chef::Node] node
|
153
|
+
#
|
154
|
+
# @return [Boolean]
|
155
|
+
#
|
156
|
+
def debian_platform?(node)
|
157
|
+
node['platform'] == 'debian'
|
158
|
+
end
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
160
|
+
#
|
161
|
+
# Determine if the current node is amazon linux.
|
162
|
+
#
|
163
|
+
# @param [Chef::Node] node
|
164
|
+
#
|
165
|
+
# @return [Boolean]
|
166
|
+
#
|
167
|
+
def amazon_linux?(node)
|
168
|
+
node['platform'] == 'amazon'
|
169
|
+
end
|
170
|
+
alias_method :amazon?, :amazon_linux?
|
169
171
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
172
|
+
#
|
173
|
+
# Determine if the current node is centos.
|
174
|
+
#
|
175
|
+
# @param [Chef::Node] node
|
176
|
+
#
|
177
|
+
# @return [Boolean]
|
178
|
+
#
|
179
|
+
def centos?(node)
|
180
|
+
node['platform'] == 'centos'
|
181
|
+
end
|
180
182
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
183
|
+
#
|
184
|
+
# Determine if the current node is oracle linux.
|
185
|
+
#
|
186
|
+
# @param [Chef::Node] node
|
187
|
+
#
|
188
|
+
# @return [Boolean]
|
189
|
+
#
|
190
|
+
def oracle_linux?(node)
|
191
|
+
node['platform'] == 'oracle'
|
192
|
+
end
|
193
|
+
alias_method :oracle?, :oracle_linux?
|
192
194
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
195
|
+
#
|
196
|
+
# Determine if the current node is scientific linux.
|
197
|
+
#
|
198
|
+
# @param [Chef::Node] node
|
199
|
+
#
|
200
|
+
# @return [Boolean]
|
201
|
+
#
|
202
|
+
def scientific_linux?(node)
|
203
|
+
node['platform'] == 'scientific'
|
204
|
+
end
|
205
|
+
alias_method :scientific?, :scientific_linux?
|
204
206
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
207
|
+
#
|
208
|
+
# Determine if the current node is redhat enterprise.
|
209
|
+
#
|
210
|
+
# @param [Chef::Node] node
|
211
|
+
#
|
212
|
+
# @return [Boolean]
|
213
|
+
#
|
214
|
+
def redhat_enterprise_linux?(node)
|
215
|
+
node['platform'] == 'redhat'
|
216
|
+
end
|
217
|
+
alias_method :redhat_enterprise?, :redhat_enterprise_linux?
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
219
|
+
#
|
220
|
+
# Determine if the current node is fedora (platform, not platform_family).
|
221
|
+
#
|
222
|
+
# @param [Chef::Node] node
|
223
|
+
#
|
224
|
+
# @return [Boolean]
|
225
|
+
#
|
226
|
+
def fedora_platform?(node)
|
227
|
+
node['platform'] == 'fedora'
|
228
|
+
end
|
227
229
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
230
|
+
#
|
231
|
+
# Determine if the current node is solaris2
|
232
|
+
#
|
233
|
+
# @param [Chef::Node] node
|
234
|
+
#
|
235
|
+
# @return [Boolean]
|
236
|
+
#
|
237
|
+
def solaris2?(node)
|
238
|
+
node['platform'] == 'solaris2'
|
239
|
+
end
|
240
|
+
alias_method :solaris?, :solaris2?
|
239
241
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
242
|
+
#
|
243
|
+
# Determine if the current node is aix
|
244
|
+
#
|
245
|
+
# @param [Chef::Node] node
|
246
|
+
#
|
247
|
+
# @return [Boolean]
|
248
|
+
#
|
249
|
+
def aix?(node)
|
250
|
+
node['platform'] == 'aix'
|
251
|
+
end
|
250
252
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
253
|
+
#
|
254
|
+
# Determine if the current node is smartos
|
255
|
+
#
|
256
|
+
# @param [Chef::Node] node
|
257
|
+
#
|
258
|
+
# @return [Boolean]
|
259
|
+
#
|
260
|
+
def smartos?(node)
|
261
|
+
node['platform'] == 'smartos'
|
262
|
+
end
|
261
263
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
264
|
+
#
|
265
|
+
# Determine if the current node is omnios
|
266
|
+
#
|
267
|
+
# @param [Chef::Node] node
|
268
|
+
#
|
269
|
+
# @return [Boolean]
|
270
|
+
#
|
271
|
+
def omnios?(node)
|
272
|
+
node['platform'] == 'omnios'
|
273
|
+
end
|
272
274
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
275
|
+
#
|
276
|
+
# Determine if the current node is raspbian
|
277
|
+
#
|
278
|
+
# @param [Chef::Node] node
|
279
|
+
#
|
280
|
+
# @return [Boolean]
|
281
|
+
#
|
282
|
+
def raspbian?(node)
|
283
|
+
node['platform'] == 'raspbian'
|
284
|
+
end
|
283
285
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
286
|
+
#
|
287
|
+
# Determine if the current node is a Cisco nexus device
|
288
|
+
#
|
289
|
+
# @param [Chef::Node] node
|
290
|
+
#
|
291
|
+
# @return [Boolean]
|
292
|
+
#
|
293
|
+
def nexus?(node)
|
294
|
+
node['platform'] == 'nexus'
|
295
|
+
end
|
296
|
+
|
297
|
+
#
|
298
|
+
# Determine if the current node is a Cisco IOS-XR device
|
299
|
+
#
|
300
|
+
# @param [Chef::Node] node
|
301
|
+
#
|
302
|
+
# @return [Boolean]
|
303
|
+
#
|
304
|
+
def ios_xr?(node)
|
305
|
+
node['platform'] == 'ios_xr'
|
306
|
+
end
|
294
307
|
|
295
|
-
#
|
296
|
-
# Determine if the current node is a Cisco IOS-XR device
|
297
|
-
#
|
298
|
-
# @param [Chef::Node] node
|
299
|
-
#
|
300
|
-
# @return [Boolean]
|
301
|
-
#
|
302
|
-
def ios_xr?(node)
|
303
|
-
node['platform'] == 'ios_xr'
|
304
308
|
end
|
305
309
|
|
306
310
|
#
|
@@ -19,152 +19,157 @@ class Chef
|
|
19
19
|
module PlatformFamily
|
20
20
|
extend self
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
#
|
25
|
-
# @param [Chef::Node] node
|
26
|
-
#
|
27
|
-
# @return [Boolean]
|
28
|
-
#
|
29
|
-
def arch_linux?(node)
|
30
|
-
node['platform_family'] == 'arch'
|
31
|
-
end
|
32
|
-
alias_method :arch?, :arch_linux?
|
33
|
-
|
34
|
-
#
|
35
|
-
# Determine if the current node is a member of the debian family.
|
36
|
-
#
|
37
|
-
# @param [Chef::Node] node
|
38
|
-
#
|
39
|
-
# @return [Boolean]
|
40
|
-
#
|
41
|
-
def debian?(node)
|
42
|
-
node['platform_family'] == 'debian'
|
43
|
-
end
|
22
|
+
# these helpers have been moved to core chef
|
23
|
+
unless Gem::Requirement.new(">= 15.4.70").satisfied_by?(Gem::Version.new(Chef::VERSION))
|
44
24
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
25
|
+
#
|
26
|
+
# Determine if the current node is a member of the arch family.
|
27
|
+
#
|
28
|
+
# @param [Chef::Node] node
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
#
|
32
|
+
def arch_linux?(node)
|
33
|
+
node['platform_family'] == 'arch'
|
34
|
+
end
|
35
|
+
alias_method :arch?, :arch_linux?
|
55
36
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
37
|
+
#
|
38
|
+
# Determine if the current node is a member of the debian family.
|
39
|
+
#
|
40
|
+
# @param [Chef::Node] node
|
41
|
+
#
|
42
|
+
# @return [Boolean]
|
43
|
+
#
|
44
|
+
def debian?(node)
|
45
|
+
node['platform_family'] == 'debian'
|
46
|
+
end
|
66
47
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
48
|
+
#
|
49
|
+
# Determine if the current node is a member of the fedora family.
|
50
|
+
#
|
51
|
+
# @param [Chef::Node] node
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
54
|
+
#
|
55
|
+
def fedora?(node)
|
56
|
+
node['platform_family'] == 'fedora'
|
57
|
+
end
|
77
58
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
alias_method :osx?, :mac_os_x?
|
89
|
-
alias_method :mac?, :mac_os_x?
|
90
|
-
|
91
|
-
#
|
92
|
-
# Determine if the current node is a member of the openbsd family.
|
93
|
-
#
|
94
|
-
# @param [Chef::Node] node
|
95
|
-
#
|
96
|
-
# @return [Boolean]
|
97
|
-
#
|
98
|
-
def openbsd?(node)
|
99
|
-
node['platform_family'] == 'openbsd'
|
100
|
-
end
|
59
|
+
#
|
60
|
+
# Determine if the current node is a member of the freebsd family.
|
61
|
+
#
|
62
|
+
# @param [Chef::Node] node
|
63
|
+
#
|
64
|
+
# @return [Boolean]
|
65
|
+
#
|
66
|
+
def freebsd?(node)
|
67
|
+
node['platform_family'] == 'freebsd'
|
68
|
+
end
|
101
69
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
alias_method :redhat?, :rhel?
|
113
|
-
alias_method :el?, :rhel?
|
114
|
-
|
115
|
-
#
|
116
|
-
# Determine if the current node is a member of the slackware family.
|
117
|
-
#
|
118
|
-
# @param [Chef::Node] node
|
119
|
-
#
|
120
|
-
# @return [Boolean]
|
121
|
-
#
|
122
|
-
def slackware?(node)
|
123
|
-
node['platform_family'] == 'slackware'
|
124
|
-
end
|
70
|
+
#
|
71
|
+
# Determine if the current node is a member of the arch family.
|
72
|
+
#
|
73
|
+
# @param [Chef::Node] node
|
74
|
+
#
|
75
|
+
# @return [Boolean]
|
76
|
+
#
|
77
|
+
def gentoo?(node)
|
78
|
+
node['platform_family'] == 'gentoo'
|
79
|
+
end
|
125
80
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
81
|
+
#
|
82
|
+
# Determine if the current node is a member of the OSX family.
|
83
|
+
#
|
84
|
+
# @param [Chef::Node] node
|
85
|
+
#
|
86
|
+
# @return [Boolean]
|
87
|
+
#
|
88
|
+
def mac_os_x?(node)
|
89
|
+
node['platform_family'] == 'mac_os_x'
|
90
|
+
end
|
91
|
+
alias_method :osx?, :mac_os_x?
|
92
|
+
alias_method :mac?, :mac_os_x?
|
136
93
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
94
|
+
#
|
95
|
+
# Determine if the current node is a member of the openbsd family.
|
96
|
+
#
|
97
|
+
# @param [Chef::Node] node
|
98
|
+
#
|
99
|
+
# @return [Boolean]
|
100
|
+
#
|
101
|
+
def openbsd?(node)
|
102
|
+
node['platform_family'] == 'openbsd'
|
103
|
+
end
|
147
104
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
105
|
+
#
|
106
|
+
# Determine if the current node is a member of the redhat family.
|
107
|
+
#
|
108
|
+
# @param [Chef::Node] node
|
109
|
+
#
|
110
|
+
# @return [Boolean]
|
111
|
+
#
|
112
|
+
def rhel?(node)
|
113
|
+
node['platform_family'] == 'rhel'
|
114
|
+
end
|
115
|
+
alias_method :redhat?, :rhel?
|
116
|
+
alias_method :el?, :rhel?
|
117
|
+
|
118
|
+
#
|
119
|
+
# Determine if the current node is a member of the slackware family.
|
120
|
+
#
|
121
|
+
# @param [Chef::Node] node
|
122
|
+
#
|
123
|
+
# @return [Boolean]
|
124
|
+
#
|
125
|
+
def slackware?(node)
|
126
|
+
node['platform_family'] == 'slackware'
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# Determine if the current node is a member of the suse family.
|
131
|
+
#
|
132
|
+
# @param [Chef::Node] node
|
133
|
+
#
|
134
|
+
# @return [Boolean]
|
135
|
+
#
|
136
|
+
def suse?(node)
|
137
|
+
node['platform_family'] == 'suse'
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# Determine if the current node is a member of the windows family.
|
142
|
+
#
|
143
|
+
# @param [Chef::Node] node
|
144
|
+
#
|
145
|
+
# @return [Boolean]
|
146
|
+
#
|
147
|
+
def windows?(node)
|
148
|
+
node['platform_family'] == 'windows'
|
149
|
+
end
|
150
|
+
|
151
|
+
#
|
152
|
+
# Determine if the current node is a member of the wrlinux family.
|
153
|
+
#
|
154
|
+
# @param [Chef::Node] node
|
155
|
+
#
|
156
|
+
# @return [Boolean]
|
157
|
+
#
|
158
|
+
def wrlinux?(node)
|
159
|
+
node['platform_family'] == 'wrlinux'
|
160
|
+
end
|
161
|
+
|
162
|
+
#
|
163
|
+
# Determine if the current system is a linux derivative
|
164
|
+
#
|
165
|
+
# @param [Chef::Node] node
|
166
|
+
#
|
167
|
+
# @return [Boolean]
|
168
|
+
#
|
169
|
+
def linux?(node)
|
170
|
+
node['os'] == 'linux'
|
171
|
+
end
|
158
172
|
|
159
|
-
#
|
160
|
-
# Determine if the current system is a linux derivative
|
161
|
-
#
|
162
|
-
# @param [Chef::Node] node
|
163
|
-
#
|
164
|
-
# @return [Boolean]
|
165
|
-
#
|
166
|
-
def linux?(node)
|
167
|
-
node['os'] == 'linux'
|
168
173
|
end
|
169
174
|
end
|
170
175
|
|
data/lib/chef/sugar/shell.rb
CHANGED
@@ -51,7 +51,11 @@ class Chef
|
|
51
51
|
# @return [String]
|
52
52
|
#
|
53
53
|
def dev_null(node)
|
54
|
-
|
54
|
+
if defined?(ChefUtils)
|
55
|
+
ChefUtils.windows?(node) ? 'NUL' : '/dev/null'
|
56
|
+
else
|
57
|
+
Chef::Sugar::PlatformFamily.windows?(node) ? 'NUL' : '/dev/null'
|
58
|
+
end
|
55
59
|
end
|
56
60
|
|
57
61
|
#
|
data/lib/chef/sugar/version.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-sugar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: chefspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: test-kitchen
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: kitchen-vagrant
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
83
13
|
description: A series of helpful sugar of the Chef core and other resources to make
|
84
14
|
a cleaner, more lean recipe DSL, enforce DRY principles, and make writing Chef recipes
|
85
15
|
an awesome experience!
|
@@ -100,6 +30,7 @@ files:
|
|
100
30
|
- lib/chef/sugar/core_extensions/object.rb
|
101
31
|
- lib/chef/sugar/core_extensions/string.rb
|
102
32
|
- lib/chef/sugar/data_bag.rb
|
33
|
+
- lib/chef/sugar/deprecation.rb
|
103
34
|
- lib/chef/sugar/docker.rb
|
104
35
|
- lib/chef/sugar/filters.rb
|
105
36
|
- lib/chef/sugar/init.rb
|
@@ -115,9 +46,9 @@ files:
|
|
115
46
|
- lib/chef/sugar/vagrant.rb
|
116
47
|
- lib/chef/sugar/version.rb
|
117
48
|
- lib/chef/sugar/virtualization.rb
|
118
|
-
homepage: https://github.com/
|
49
|
+
homepage: https://github.com/chef/chef-sugar
|
119
50
|
licenses:
|
120
|
-
- Apache
|
51
|
+
- Apache-2.0
|
121
52
|
metadata: {}
|
122
53
|
post_install_message:
|
123
54
|
rdoc_options: []
|
@@ -127,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
58
|
requirements:
|
128
59
|
- - ">="
|
129
60
|
- !ruby/object:Gem::Version
|
130
|
-
version: 2.
|
61
|
+
version: '2.3'
|
131
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
63
|
requirements:
|
133
64
|
- - ">="
|