chef-sugar 4.2.1 → 5.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/sugar/architecture.rb +137 -132
  3. data/{recipes/default.rb → lib/chef/sugar/deprecation.rb} +31 -6
  4. data/lib/chef/sugar/docker.rb +17 -12
  5. data/lib/chef/sugar/init.rb +1 -2
  6. data/lib/chef/sugar/kitchen.rb +17 -12
  7. data/lib/chef/sugar/node.rb +6 -0
  8. data/lib/chef/sugar/platform.rb +169 -165
  9. data/lib/chef/sugar/platform_family.rb +142 -137
  10. data/lib/chef/sugar/shell.rb +7 -3
  11. data/lib/chef/sugar/version.rb +1 -1
  12. data/lib/chef/sugar/virtualization.rb +1 -1
  13. metadata +9 -139
  14. data/.github/lock.yml +0 -3
  15. data/.github/reaction.yml +0 -1
  16. data/.gitignore +0 -26
  17. data/.kitchen.yml +0 -16
  18. data/.travis.yml +0 -17
  19. data/CHANGELOG.md +0 -261
  20. data/CONTRIBUTING.md +0 -20
  21. data/Gemfile +0 -2
  22. data/README.md +0 -540
  23. data/Rakefile +0 -11
  24. data/chef-sugar.gemspec +0 -33
  25. data/libraries/chef-sugar.rb +0 -1
  26. data/metadata.rb +0 -24
  27. data/spec/spec_helper.rb +0 -25
  28. data/spec/support/shared_examples.rb +0 -20
  29. data/spec/unit/chef/sugar/architecture_spec.rb +0 -129
  30. data/spec/unit/chef/sugar/cloud_spec.rb +0 -149
  31. data/spec/unit/chef/sugar/constraints_spec.rb +0 -45
  32. data/spec/unit/chef/sugar/core_extensions/array_spec.rb +0 -10
  33. data/spec/unit/chef/sugar/core_extensions/object_spec.rb +0 -62
  34. data/spec/unit/chef/sugar/core_extensions/string_spec.rb +0 -48
  35. data/spec/unit/chef/sugar/data_bag_spec.rb +0 -118
  36. data/spec/unit/chef/sugar/docker_spec.rb +0 -39
  37. data/spec/unit/chef/sugar/init_spec.rb +0 -74
  38. data/spec/unit/chef/sugar/ip_spec.rb +0 -53
  39. data/spec/unit/chef/sugar/kernel_spec.rb +0 -16
  40. data/spec/unit/chef/sugar/kitchen_spec.rb +0 -18
  41. data/spec/unit/chef/sugar/node_spec.rb +0 -172
  42. data/spec/unit/chef/sugar/platform_family_spec.rb +0 -166
  43. data/spec/unit/chef/sugar/platform_spec.rb +0 -342
  44. data/spec/unit/chef/sugar/ruby_spec.rb +0 -39
  45. data/spec/unit/chef/sugar/run_context_spec.rb +0 -19
  46. data/spec/unit/chef/sugar/shell_spec.rb +0 -104
  47. data/spec/unit/chef/sugar/vagrant_spec.rb +0 -37
  48. data/spec/unit/chef/sugar/virtualization_spec.rb +0 -135
  49. data/spec/unit/recipes/default_spec.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa1a33f83e2bea5058d88c52bcba91d40efe2a8983572b72f2a78af957c32e34
4
- data.tar.gz: ca6ada3aba96848baa7fb136a87a2d58a79c3c1994cad3c2790940c1612dc387
3
+ metadata.gz: 690f59ffaeb7464fa9481cb0c30dee73950e32c86012ecf5c6a44c944cb695c2
4
+ data.tar.gz: b76c63eeb5479c9af859397c1b0bc10d2f7f7082586013462b8d63ecccb9fb33
5
5
  SHA512:
6
- metadata.gz: f01a47a1e0de0bf0c121fdfd119b4f9127c64615b6de6c54e281b2670917c3dc0ad40a7a7fcb7b687843d74e5f37e3907b8c2246654b96323d83386a0010243f
7
- data.tar.gz: 648cb71624cb4d94003dafe8efaa556c688b71d5fb50c72c9d95ddb039857561dab678ec875b94d2ddd8056552408e41c0bcd8fe117ba4be7463f6dc5ce09bea
6
+ metadata.gz: 2d2d0f8894504caeacff01c363300b300ffd776bb71ba0005ff316cc312c4c5726bee7fd2c0afa81cac6b30c2c62eb666a1acd14bb681ae30f736fcb777796c5
7
+ data.tar.gz: 5962221ffaacb4ec6fcb56234aad9d850b324db2d94c1ddffc012e64cf44ede469942ccdce336ac7844a7510f1a26ffd9e76052e7d0e385f0566067162b262a0
@@ -19,153 +19,158 @@ class Chef
19
19
  module Architecture
20
20
  extend self
21
21
 
22
- #
23
- # Determine if the current architecture is 64-bit
24
- #
25
- # @return [Boolean]
26
- #
27
- def _64_bit?(node)
28
- %w(amd64 x86_64 ppc64 ppc64le s390x ia64 sparc64 aarch64 arch64 arm64 sun4v sun4u s390x)
29
- .include?(node['kernel']['machine']) || ( node['kernel']['bits'] == '64' )
30
- end
31
-
32
- #
33
- # Determine if the current architecture is 32-bit
34
- #
35
- # @todo Make this more than "not 64-bit"
36
- #
37
- # @return [Boolean]
38
- #
39
- def _32_bit?(node)
40
- !_64_bit?(node)
41
- end
42
-
43
- #
44
- # Determine if the current architecture is i386
45
- #
46
- # @return [Boolean]
47
- #
48
- def i386?(node)
49
- _32_bit?(node) && intel?(node)
50
- end
51
-
52
- #
53
- # Determine if the current architecture is Intel.
54
- #
55
- # @return [Boolean]
56
- #
57
- def intel?(node)
58
- %w(i86pc i386 x86_64 amd64 i686)
59
- .include?(node['kernel']['machine'])
60
- end
61
-
62
- #
63
- # Determine if the current architecture is SPARC.
64
- #
65
- # @return [Boolean]
66
- #
67
- def sparc?(node)
68
- %w(sun4u sun4v)
69
- .include?(node['kernel']['machine'])
70
- end
71
-
72
- #
73
- # Determine if the current architecture is Powerpc64 Big Endian
74
- #
75
- # @return [Boolean]
76
- #
77
- def ppc64?(node)
78
- %w(ppc64)
79
- .include?(node['kernel']['machine'])
80
- end
81
-
82
- #
83
- # Determine if the current architecture is Powerpc64 Little Endian
84
- #
85
- # @return [Boolean]
86
- #
87
- def ppc64le?(node)
88
- %w(ppc64le)
89
- .include?(node['kernel']['machine'])
90
- end
91
-
92
- #
93
- # Determine if the current architecture is PowerPC
94
- #
95
- # @return [Boolean]
96
- #
97
- def powerpc?(node)
98
- %w(powerpc)
99
- .include?(node['kernel']['machine'])
100
- end
101
-
102
- #
103
- # Determine if the current architecture is ARM with Hard Float
104
- #
105
- # @return [Boolean]
106
- #
107
- def armhf?(node)
108
- # Add more arm variants as needed here
109
- %w(armv6l armv7l)
110
- .include?(node['kernel']['machine'])
111
- end
112
-
113
- #
114
- # Determine if the current architecture is AArch64
115
- #
116
- # @return [Boolean]
117
- #
118
- def aarch64?(node)
119
- # Add more arm variants as needed here
120
- %w(aarch64)
121
- .include?(node['kernel']['machine'])
122
- end
123
-
124
- #
125
- # Determine if the current architecture is s390x
126
- #
127
- # @return [Boolean]
128
- #
129
- def s390x?(node)
130
- %w(s390x)
131
- .include?(node['kernel']['machine'])
22
+ # these helpers have been moved to core-chef
23
+ if !defined?(Chef::VERSION) || 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
- # @see Chef::Sugar::Architecture#_64_bit?
137
- def _64_bit?; Chef::Sugar::Architecture._64_bit?(node); end
139
+ if !defined?(Chef::VERSION) || 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
- # @see Chef::Sugar::Architecture#_32_bit?
140
- def _32_bit?; Chef::Sugar::Architecture._32_bit?(node); end
143
+ # @see Chef::Sugar::Architecture#_32_bit?
144
+ def _32_bit?; Chef::Sugar::Architecture._32_bit?(node); end
141
145
 
142
- # @see Chef::Sugar::Architecture#intel?
143
- def i386?; Chef::Sugar::Architecture.i386?(node); end
146
+ # @see Chef::Sugar::Architecture#intel?
147
+ def i386?; Chef::Sugar::Architecture.i386?(node); end
144
148
 
145
- # @see Chef::Sugar::Architecture#intel?
146
- def intel?; Chef::Sugar::Architecture.intel?(node); end
149
+ # @see Chef::Sugar::Architecture#intel?
150
+ def intel?; Chef::Sugar::Architecture.intel?(node); end
147
151
 
148
- # @see Chef::Sugar::Architecture#sparc?
149
- def sparc?; Chef::Sugar::Architecture.sparc?(node); end
152
+ # @see Chef::Sugar::Architecture#sparc?
153
+ def sparc?; Chef::Sugar::Architecture.sparc?(node); end
150
154
 
151
- # @see Chef::Sugar::Architecture#ppc64?
152
- def ppc64?; Chef::Sugar::Architecture.ppc64?(node); end
155
+ # @see Chef::Sugar::Architecture#ppc64?
156
+ def ppc64?; Chef::Sugar::Architecture.ppc64?(node); end
153
157
 
154
- # @see Chef::Sugar::Architecture#ppc64le?
155
- def ppc64le?; Chef::Sugar::Architecture.ppc64le?(node); end
158
+ # @see Chef::Sugar::Architecture#ppc64le?
159
+ def ppc64le?; Chef::Sugar::Architecture.ppc64le?(node); end
156
160
 
157
- # @see Chef::Sugar::Architecture#powerpc?
158
- def powerpc?; Chef::Sugar::Architecture.powerpc?(node); end
161
+ # @see Chef::Sugar::Architecture#powerpc?
162
+ def powerpc?; Chef::Sugar::Architecture.powerpc?(node); end
159
163
 
160
- # @see Chef::Sugar::Architecture#arm?
161
- def armhf?; Chef::Sugar::Architecture.armhf?(node); end
164
+ # @see Chef::Sugar::Architecture#arm?
165
+ def armhf?; Chef::Sugar::Architecture.armhf?(node); end
162
166
 
163
- # @see Chef::Sugar::Architecture#aarch64?
164
- def aarch64?; Chef::Sugar::Architecture.aarch64?(node); end
167
+ # @see Chef::Sugar::Architecture#aarch64?
168
+ def aarch64?; Chef::Sugar::Architecture.aarch64?(node); end
165
169
 
166
- # @see Chef::Sugar::Architecture#s390x?
167
- def s390x?; Chef::Sugar::Architecture.s390x?(node); end
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
@@ -1,9 +1,4 @@
1
1
  #
2
- # Cookbook Name:: chef-sugar
3
- # Recipe:: default
4
- #
5
- # Copyright 2013-2015, Seth Vargo <sethvargo@gmail.com>
6
- #
7
2
  # Licensed under the Apache License, Version 2.0 (the "License");
8
3
  # you may not use this file except in compliance with the License.
9
4
  # You may obtain a copy of the License at
@@ -17,4 +12,34 @@
17
12
  # limitations under the License.
18
13
  #
19
14
 
20
- Chef::Log.warn('chef-sugar::default no longer needs to be included in your runlist. Instead simply depend on the chef-sugar cookbook and the gem will be intalled and loaded automatically.')
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
@@ -19,22 +19,27 @@ class Chef
19
19
  module Docker
20
20
  extend self
21
21
 
22
- #
23
- # Returns true if the current node is a docker container.
24
- #
25
- # @param [Chef::Node] node
26
- # the node to check
27
- #
28
- # @return [Boolean]
29
- #
30
- def docker?(node)
31
- File.exist?('/.dockerinit') || File.exist?('/.dockerenv')
22
+ # these helpers have been moved to core chef
23
+ if !defined?(Chef::VERSION) || 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
- # @see Chef::Sugar::Docker#docker?
37
- def docker?; Chef::Sugar::Docker.docker?(node); end
39
+ if !defined?(Chef::VERSION) || 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
@@ -25,8 +25,7 @@ class Chef
25
25
  # @return [Boolean]
26
26
  #
27
27
  def systemd?(node)
28
- file = '/proc/1/comm'
29
- File.exist?(file) && IO.read(file).chomp == 'systemd'
28
+ File.exist?('/bin/systemctl')
30
29
  end
31
30
 
32
31
  #
@@ -19,22 +19,27 @@ class Chef
19
19
  module Kitchen
20
20
  extend self
21
21
 
22
- #
23
- # Returns true if the current node is provisioned by Test Kitchen.
24
- #
25
- # @param [Chef::Node] node
26
- # the node to check
27
- #
28
- # @return [Boolean]
29
- #
30
- def kitchen?(node)
31
- !ENV['TEST_KITCHEN'].nil?
22
+ # these helpers have been moved to core-chef
23
+ if !defined?(Chef::VERSION) || 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
- # @see Chef::Sugar::Kitchen#kitchen?
37
- def kitchen?; Chef::Sugar::Kitchen.kitchen?(node); end
39
+ if !defined?(Chef::VERSION) || 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
@@ -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)