chef-utils 15.7.32 → 15.11.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef-utils.rb +11 -4
- data/lib/chef-utils/dsl/architecture.rb +42 -10
- data/lib/chef-utils/dsl/cloud.rb +143 -0
- data/lib/chef-utils/dsl/introspection.rb +24 -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 +135 -90
- data/lib/chef-utils/dsl/platform_family.rb +70 -39
- data/lib/chef-utils/dsl/platform_version.rb +40 -0
- data/lib/chef-utils/dsl/service.rb +20 -1
- data/lib/chef-utils/dsl/train_helpers.rb +2 -2
- data/lib/chef-utils/dsl/virtualization.rb +249 -0
- data/lib/chef-utils/dsl/which.rb +1 -1
- data/lib/chef-utils/dsl/windows.rb +33 -6
- data/lib/chef-utils/internal.rb +1 -1
- data/lib/chef-utils/version.rb +2 -2
- data/lib/chef-utils/version_string.rb +6 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/unit/dsl/architecture_spec.rb +16 -5
- data/spec/unit/dsl/cloud_spec.rb +88 -0
- data/spec/unit/dsl/dsl_spec.rb +1 -1
- data/spec/unit/dsl/introspection_spec.rb +20 -1
- 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 +74 -0
- data/spec/unit/dsl/which_spec.rb +1 -1
- data/spec/unit/dsl/windows_spec.rb +32 -12
- data/spec/unit/mash_spec.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a926b8a7f54e03d457db79b651d0be61ec103c51c3910fe480d449ab550571ba
|
4
|
+
data.tar.gz: 9189b342fec5fe66f1e4a8b847139203c1cfdd8fc9c2cfe370bf436609808c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7a1a3174a9e5b7a914d85df41792a5ac7a148206a86fe919d213d1947082252aeacff37667a1d504491dbb44d39b84a732637aabe919cfd9857bc24a882999
|
7
|
+
data.tar.gz: 011d32fc1d2efd8e5affd4fd48ca1c0484975fcad34e2e3f5eab8bd11aebbb9287f9f5c5238a5e531bf8e341a34e1c4b805482573c80acb272536644f5155574
|
data/lib/chef-utils.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");
|
@@ -16,24 +16,31 @@
|
|
16
16
|
#
|
17
17
|
|
18
18
|
require_relative "chef-utils/dsl/architecture"
|
19
|
+
require_relative "chef-utils/dsl/cloud"
|
19
20
|
require_relative "chef-utils/dsl/introspection"
|
20
21
|
require_relative "chef-utils/dsl/os"
|
21
22
|
require_relative "chef-utils/dsl/path_sanity"
|
22
23
|
require_relative "chef-utils/dsl/platform"
|
23
24
|
require_relative "chef-utils/dsl/platform_family"
|
25
|
+
require_relative "chef-utils/dsl/platform_version"
|
24
26
|
require_relative "chef-utils/dsl/service"
|
25
27
|
require_relative "chef-utils/dsl/train_helpers"
|
28
|
+
require_relative "chef-utils/dsl/virtualization"
|
26
29
|
require_relative "chef-utils/dsl/which"
|
27
30
|
require_relative "chef-utils/dsl/windows"
|
28
31
|
require_relative "chef-utils/mash"
|
29
32
|
|
30
|
-
# This is the Chef Infra Client DSL, not
|
33
|
+
# This is the Chef Infra Client DSL, not everything needs to go in here
|
31
34
|
module ChefUtils
|
32
35
|
include ChefUtils::DSL::Architecture
|
36
|
+
include ChefUtils::DSL::Cloud
|
37
|
+
include ChefUtils::DSL::Introspection
|
33
38
|
include ChefUtils::DSL::OS
|
34
|
-
include ChefUtils::DSL::PlatformFamily
|
35
39
|
include ChefUtils::DSL::Platform
|
36
|
-
include ChefUtils::DSL::
|
40
|
+
include ChefUtils::DSL::PlatformFamily
|
41
|
+
include ChefUtils::DSL::PlatformVersion
|
42
|
+
include ChefUtils::DSL::TrainHelpers
|
43
|
+
include ChefUtils::DSL::Virtualization
|
37
44
|
include ChefUtils::DSL::Windows
|
38
45
|
# FIXME: include ChefUtils::DSL::Which in Chef 16.0
|
39
46
|
# FIXME: include ChefUtils::DSL::PathSanity in Chef 16.0
|
@@ -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");
|
@@ -22,7 +22,9 @@ module ChefUtils
|
|
22
22
|
module Architecture
|
23
23
|
include Internal
|
24
24
|
|
25
|
-
# Determine if the current architecture is 64-bit
|
25
|
+
# Determine if the current architecture is 64-bit.
|
26
|
+
#
|
27
|
+
# @since 15.5
|
26
28
|
#
|
27
29
|
# @return [Boolean]
|
28
30
|
#
|
@@ -31,7 +33,9 @@ module ChefUtils
|
|
31
33
|
.include?(node["kernel"]["machine"])
|
32
34
|
end
|
33
35
|
|
34
|
-
# Determine if the current architecture is 32-bit
|
36
|
+
# Determine if the current architecture is 32-bit.
|
37
|
+
#
|
38
|
+
# @since 15.5
|
35
39
|
#
|
36
40
|
# @return [Boolean]
|
37
41
|
#
|
@@ -39,7 +43,9 @@ module ChefUtils
|
|
39
43
|
!_64_bit?(node)
|
40
44
|
end
|
41
45
|
|
42
|
-
# Determine if the current architecture is i386
|
46
|
+
# Determine if the current architecture is i386.
|
47
|
+
#
|
48
|
+
# @since 15.5
|
43
49
|
#
|
44
50
|
# @return [Boolean]
|
45
51
|
#
|
@@ -49,6 +55,8 @@ module ChefUtils
|
|
49
55
|
|
50
56
|
# Determine if the current architecture is Intel.
|
51
57
|
#
|
58
|
+
# @since 15.5
|
59
|
+
#
|
52
60
|
# @return [Boolean]
|
53
61
|
#
|
54
62
|
def intel?(node = __getnode)
|
@@ -57,13 +65,17 @@ module ChefUtils
|
|
57
65
|
|
58
66
|
# Determine if the current architecture is SPARC.
|
59
67
|
#
|
68
|
+
# @since 15.5
|
69
|
+
#
|
60
70
|
# @return [Boolean]
|
61
71
|
#
|
62
72
|
def sparc?(node = __getnode)
|
63
73
|
%w{sun4u sun4v}.include?(node["kernel"]["machine"])
|
64
74
|
end
|
65
75
|
|
66
|
-
# Determine if the current architecture is PowerPC 64bit Big Endian
|
76
|
+
# Determine if the current architecture is PowerPC 64bit Big Endian.
|
77
|
+
#
|
78
|
+
# @since 15.5
|
67
79
|
#
|
68
80
|
# @return [Boolean]
|
69
81
|
#
|
@@ -71,7 +83,9 @@ module ChefUtils
|
|
71
83
|
%w{ppc64}.include?(node["kernel"]["machine"])
|
72
84
|
end
|
73
85
|
|
74
|
-
# Determine if the current architecture is PowerPC 64bit Little Endian
|
86
|
+
# Determine if the current architecture is PowerPC 64bit Little Endian.
|
87
|
+
#
|
88
|
+
# @since 15.5
|
75
89
|
#
|
76
90
|
# @return [Boolean]
|
77
91
|
#
|
@@ -81,21 +95,37 @@ module ChefUtils
|
|
81
95
|
|
82
96
|
# Determine if the current architecture is PowerPC.
|
83
97
|
#
|
98
|
+
# @since 15.5
|
99
|
+
#
|
84
100
|
# @return [Boolean]
|
85
101
|
#
|
86
102
|
def powerpc?(node = __getnode)
|
87
103
|
%w{powerpc}.include?(node["kernel"]["machine"])
|
88
104
|
end
|
89
105
|
|
90
|
-
# Determine if the current architecture is
|
106
|
+
# Determine if the current architecture is arm
|
107
|
+
#
|
108
|
+
# @since 15.10
|
109
|
+
#
|
110
|
+
# @return [Boolean]
|
111
|
+
#
|
112
|
+
def arm?(node = __getnode)
|
113
|
+
%w{armv6l armv7l armhf aarch64 arm64 arch64}.include?(node["kernel"]["machine"])
|
114
|
+
end
|
115
|
+
|
116
|
+
# Determine if the current architecture is 32-bit ARM hard float.
|
117
|
+
#
|
118
|
+
# @since 15.5
|
91
119
|
#
|
92
120
|
# @return [Boolean]
|
93
121
|
#
|
94
122
|
def armhf?(node = __getnode)
|
95
|
-
%w{armhf}.include?(node["kernel"]["machine"])
|
123
|
+
%w{armv6l armv7l armhf}.include?(node["kernel"]["machine"])
|
96
124
|
end
|
97
125
|
|
98
|
-
# Determine if the current architecture is s390x
|
126
|
+
# Determine if the current architecture is s390x.
|
127
|
+
#
|
128
|
+
# @since 15.5
|
99
129
|
#
|
100
130
|
# @return [Boolean]
|
101
131
|
#
|
@@ -103,7 +133,9 @@ module ChefUtils
|
|
103
133
|
%w{s390x}.include?(node["kernel"]["machine"])
|
104
134
|
end
|
105
135
|
|
106
|
-
# Determine if the current architecture is s390
|
136
|
+
# Determine if the current architecture is s390.
|
137
|
+
#
|
138
|
+
# @since 15.5
|
107
139
|
#
|
108
140
|
# @return [Boolean]
|
109
141
|
#
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 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 Cloud
|
23
|
+
include Internal
|
24
|
+
|
25
|
+
# Determine if the current node is "in the cloud".
|
26
|
+
#
|
27
|
+
# @param [Chef::Node] node the node to check
|
28
|
+
# @since 15.8
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
#
|
32
|
+
def cloud?(node = __getnode)
|
33
|
+
# cloud is always present, but nil if not on a cloud
|
34
|
+
!node["cloud"].nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return true if the current current node is in EC2.
|
38
|
+
#
|
39
|
+
# @param [Chef::Node] node the node to check
|
40
|
+
# @since 15.8
|
41
|
+
#
|
42
|
+
# @return [Boolean]
|
43
|
+
#
|
44
|
+
def ec2?(node = __getnode)
|
45
|
+
node.key?("ec2")
|
46
|
+
end
|
47
|
+
|
48
|
+
# Return true if the current current node is in GCE.
|
49
|
+
#
|
50
|
+
# @param [Chef::Node] node the node to check
|
51
|
+
# @since 15.8
|
52
|
+
#
|
53
|
+
# @return [Boolean]
|
54
|
+
#
|
55
|
+
def gce?(node = __getnode)
|
56
|
+
node.key?("gce")
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return true if the current current node is in Rackspace.
|
60
|
+
#
|
61
|
+
# @param [Chef::Node] node the node to check
|
62
|
+
# @since 15.8
|
63
|
+
#
|
64
|
+
# @return [Boolean]
|
65
|
+
#
|
66
|
+
def rackspace?(node = __getnode)
|
67
|
+
node.key?("rackspace")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Return true if the current current node is in Eucalyptus.
|
71
|
+
#
|
72
|
+
# @param [Chef::Node] node the node to check
|
73
|
+
# @since 15.8
|
74
|
+
#
|
75
|
+
# @return [Boolean]
|
76
|
+
#
|
77
|
+
def eucalyptus?(node = __getnode)
|
78
|
+
node.key?("eucalyptus")
|
79
|
+
end
|
80
|
+
# chef-sugar backcompat method
|
81
|
+
alias_method :euca?, :eucalyptus?
|
82
|
+
|
83
|
+
# Return true if the current current node is in Linode.
|
84
|
+
#
|
85
|
+
# @param [Chef::Node] node the node to check
|
86
|
+
# @since 15.8
|
87
|
+
#
|
88
|
+
# @return [Boolean]
|
89
|
+
#
|
90
|
+
def linode?(node = __getnode)
|
91
|
+
node.key?("linode")
|
92
|
+
end
|
93
|
+
|
94
|
+
# Return true if the current current node is in OpenStack.
|
95
|
+
#
|
96
|
+
# @param [Chef::Node] node the node to check
|
97
|
+
# @since 15.8
|
98
|
+
#
|
99
|
+
# @return [Boolean]
|
100
|
+
#
|
101
|
+
def openstack?(node = __getnode)
|
102
|
+
node.key?("openstack")
|
103
|
+
end
|
104
|
+
|
105
|
+
# Return true if the current current node is in Azure.
|
106
|
+
#
|
107
|
+
# @param [Chef::Node] node the node to check
|
108
|
+
# @since 15.8
|
109
|
+
#
|
110
|
+
# @return [Boolean]
|
111
|
+
#
|
112
|
+
def azure?(node = __getnode)
|
113
|
+
node.key?("azure")
|
114
|
+
end
|
115
|
+
|
116
|
+
# Return true if the current current node is in DigitalOcean.
|
117
|
+
#
|
118
|
+
# @param [Chef::Node] node the node to check
|
119
|
+
# @since 15.8
|
120
|
+
#
|
121
|
+
# @return [Boolean]
|
122
|
+
#
|
123
|
+
def digital_ocean?(node = __getnode)
|
124
|
+
node.key?("digital_ocean")
|
125
|
+
end
|
126
|
+
# chef-sugar backcompat method
|
127
|
+
alias_method :digitalocean?, :digital_ocean?
|
128
|
+
|
129
|
+
# Return true if the current current node is in SoftLayer.
|
130
|
+
#
|
131
|
+
# @param [Chef::Node] node the node to check
|
132
|
+
# @since 15.8
|
133
|
+
#
|
134
|
+
# @return [Boolean]
|
135
|
+
#
|
136
|
+
def softlayer?(node = __getnode)
|
137
|
+
node.key?("softlayer")
|
138
|
+
end
|
139
|
+
|
140
|
+
extend self
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -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");
|
@@ -30,7 +30,8 @@ module ChefUtils
|
|
30
30
|
|
31
31
|
# Determine if the node is a docker container.
|
32
32
|
#
|
33
|
-
# @param [Chef::Node] node
|
33
|
+
# @param [Chef::Node] node the node to check
|
34
|
+
# @since 15.5
|
34
35
|
#
|
35
36
|
# @return [Boolean]
|
36
37
|
#
|
@@ -42,7 +43,8 @@ module ChefUtils
|
|
42
43
|
|
43
44
|
# Determine if the node uses the systemd init system.
|
44
45
|
#
|
45
|
-
# @param [Chef::Node] node
|
46
|
+
# @param [Chef::Node] node the node to check
|
47
|
+
# @since 15.5
|
46
48
|
#
|
47
49
|
# @return [Boolean]
|
48
50
|
#
|
@@ -52,7 +54,8 @@ module ChefUtils
|
|
52
54
|
|
53
55
|
# Determine if the node is running in Test Kitchen.
|
54
56
|
#
|
55
|
-
# @param [Chef::Node] node
|
57
|
+
# @param [Chef::Node] node the node to check
|
58
|
+
# @since 15.5
|
56
59
|
#
|
57
60
|
# @return [Boolean]
|
58
61
|
#
|
@@ -62,7 +65,8 @@ module ChefUtils
|
|
62
65
|
|
63
66
|
# Determine if the node is running in a CI system that sets the CI env var.
|
64
67
|
#
|
65
|
-
# @param [Chef::Node] node
|
68
|
+
# @param [Chef::Node] node the node to check
|
69
|
+
# @since 15.5
|
66
70
|
#
|
67
71
|
# @return [Boolean]
|
68
72
|
#
|
@@ -73,6 +77,7 @@ module ChefUtils
|
|
73
77
|
# Determine if the a systemd service unit is present on the system.
|
74
78
|
#
|
75
79
|
# @param [String] svc_name
|
80
|
+
# @since 15.5
|
76
81
|
#
|
77
82
|
# @return [Boolean]
|
78
83
|
#
|
@@ -87,6 +92,7 @@ module ChefUtils
|
|
87
92
|
# Determine if the a systemd unit of any type is present on the system.
|
88
93
|
#
|
89
94
|
# @param [String] svc_name
|
95
|
+
# @since 15.5
|
90
96
|
#
|
91
97
|
# @return [Boolean]
|
92
98
|
#
|
@@ -97,6 +103,19 @@ module ChefUtils
|
|
97
103
|
end
|
98
104
|
end
|
99
105
|
|
106
|
+
# Determine if the current node includes the given recipe name.
|
107
|
+
#
|
108
|
+
# @param [String] recipe_name
|
109
|
+
# @since 15.8
|
110
|
+
#
|
111
|
+
# @return [Boolean]
|
112
|
+
#
|
113
|
+
def includes_recipe?(recipe_name, node = __getnode)
|
114
|
+
node.recipe?(recipe_name)
|
115
|
+
end
|
116
|
+
# chef-sugar backcompat method
|
117
|
+
alias_method :include_recipe?, :includes_recipe?
|
118
|
+
|
100
119
|
extend self
|
101
120
|
end
|
102
121
|
end
|
data/lib/chef-utils/dsl/os.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");
|
@@ -29,9 +29,10 @@ module ChefUtils
|
|
29
29
|
# only the platform helper should be added.
|
30
30
|
#
|
31
31
|
|
32
|
-
# Determine if the current node is
|
32
|
+
# Determine if the current node is Linux.
|
33
33
|
#
|
34
|
-
# @param [Chef::Node] node
|
34
|
+
# @param [Chef::Node] node the node to check
|
35
|
+
# @since 15.5
|
35
36
|
#
|
36
37
|
# @return [Boolean]
|
37
38
|
#
|
@@ -39,9 +40,10 @@ module ChefUtils
|
|
39
40
|
node["os"] == "linux"
|
40
41
|
end
|
41
42
|
|
42
|
-
# Determine if the current node is
|
43
|
+
# Determine if the current node is Darwin.
|
43
44
|
#
|
44
|
-
# @param [Chef::Node] node
|
45
|
+
# @param [Chef::Node] node the node to check
|
46
|
+
# @since 15.5
|
45
47
|
#
|
46
48
|
# @return [Boolean]
|
47
49
|
#
|
@@ -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");
|
@@ -23,6 +23,7 @@ module ChefUtils
|
|
23
23
|
module PathSanity
|
24
24
|
include Internal
|
25
25
|
|
26
|
+
# @since 15.5
|
26
27
|
def sanitized_path(env = nil)
|
27
28
|
env_path = env ? env["PATH"] : __env_path
|
28
29
|
env_path = "" if env_path.nil?
|