chef-config 12.5.0.alpha.1 → 12.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd54bc8331a2e6d540b5a40c05e99b22d3b0095c
4
- data.tar.gz: ccb9d11331515e4a4bbc382948b8029b5c81e08f
3
+ metadata.gz: 3434a9979123f796c68bcf60049eff88bf93ce83
4
+ data.tar.gz: b33597d8c90263a4bea0a4358e804be0ff065e32
5
5
  SHA512:
6
- metadata.gz: f4ed481b18587a5e02f5aa0ed30d0502b79dfafadfc4a7d4b86e48485b40bf191a71b868bbe37f6937dee03c1a528c7956220fbd9ff8f9b19fe82645cfe3fbd5
7
- data.tar.gz: 9e980cf78672ae314dc33993ce574f4c5a7f23f4afaaf2484ba7a3e86feaf1240ad3b10b073cb661573b224caa2151693aff4942c8c5b45901cbd13f0dc55650
6
+ metadata.gz: c5d6bf5b9ad5b89e4001068ab2161d1a99b3f14aa6d35d996f40f4642525067dc3947547bba72efd6f7c45bc40b81e25733fcd8d3c800de9f5b587a2b63351bc
7
+ data.tar.gz: 8c55a928932d2a60299b39166777ae0f3fc538d069a1083d749c4496f4552d8dff17b0a4a9fc681fbb306c275363e85f12adefc788a0fde54bcf5522aa2b65ba
data/Rakefile CHANGED
@@ -1,26 +1,8 @@
1
1
  require 'rspec/core/rake_task'
2
- require 'rubygems/package_task'
2
+ require 'chef-config/package_task'
3
3
 
4
- VERSION = IO.read(File.expand_path("../../VERSION", __FILE__)).strip
5
-
6
- Dir[File.expand_path("../*gemspec", __FILE__)].reverse.each do |gemspec_path|
7
- gemspec = eval(IO.read(gemspec_path))
8
- Gem::PackageTask.new(gemspec).define
9
- end
10
-
11
- def with_clean_env(&block)
12
- if defined?(Bundler)
13
- Bundler.with_clean_env(&block)
14
- else
15
- block.call
16
- end
17
- end
18
-
19
- desc "Build and install a chef-config gem"
20
- task :install => [:package] do
21
- with_clean_env do
22
- sh(%{gem install pkg/chef-config-#{ChefConfig::VERSION}.gem --no-rdoc --no-ri}, verbose: true)
23
- end
4
+ ChefConfig::PackageTask.new(File.expand_path('..', __FILE__), 'ChefConfig') do |package|
5
+ package.module_path = 'chef-config'
24
6
  end
25
7
 
26
8
  task :default => :spec
@@ -30,36 +12,3 @@ RSpec::Core::RakeTask.new(:spec) do |t|
30
12
  t.pattern = FileList['spec/**/*_spec.rb']
31
13
  end
32
14
 
33
- desc "Regenerate lib/chef/version.rb from VERSION file"
34
- task :version do
35
- contents = <<-VERSION_RB
36
- # Copyright:: Copyright (c) 2010-2015 Chef Software, Inc.
37
- # License:: Apache License, Version 2.0
38
- #
39
- # Licensed under the Apache License, Version 2.0 (the "License");
40
- # you may not use this file except in compliance with the License.
41
- # You may obtain a copy of the License at
42
- #
43
- # http://www.apache.org/licenses/LICENSE-2.0
44
- #
45
- # Unless required by applicable law or agreed to in writing, software
46
- # distributed under the License is distributed on an "AS IS" BASIS,
47
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- # See the License for the specific language governing permissions and
49
- # limitations under the License.
50
-
51
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
52
- # NOTE: This file is generated by running `rake version` in the top level of
53
- # this repo. Do not edit this manually. Edit the VERSION file and run the rake
54
- # task instead.
55
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
56
-
57
- module ChefConfig
58
- VERSION = '#{VERSION}'
59
- end
60
-
61
- VERSION_RB
62
- version_rb_path = File.expand_path("../lib/chef-config/version.rb", __FILE__)
63
- IO.write(version_rb_path, contents)
64
- end
65
-
@@ -68,7 +68,7 @@ module ChefConfig
68
68
 
69
69
  default(:config_dir) do
70
70
  if config_file
71
- PathHelper.dirname(config_file)
71
+ PathHelper.dirname(PathHelper.canonical_path(config_file, false))
72
72
  else
73
73
  PathHelper.join(user_home, ".chef", "")
74
74
  end
@@ -128,7 +128,7 @@ module ChefConfig
128
128
  if chef_repo_path.kind_of?(String)
129
129
  PathHelper.join(chef_repo_path, child_path)
130
130
  else
131
- chef_repo_path.map { |path| PathHelper.join(path, child_path)}
131
+ chef_repo_path.uniq.map { |path| PathHelper.join(path, child_path)}
132
132
  end
133
133
  end
134
134
 
@@ -339,10 +339,33 @@ module ChefConfig
339
339
  # most of our testing scenarios)
340
340
  default :minimal_ohai, false
341
341
 
342
+ ###
343
+ # Policyfile Settings
344
+ #
342
345
  # Policyfile is a feature where a node gets its run list and cookbook
343
346
  # version set from a single document on the server instead of expanding the
344
347
  # run list and having the server compute the cookbook version set based on
345
348
  # environment constraints.
349
+ #
350
+ # Policyfiles are auto-versioned. The user groups nodes by `policy_name`,
351
+ # which generally describes a hosts's functional role, and `policy_group`,
352
+ # which generally groups nodes by deployment phase (a.k.a., "environment").
353
+ # The Chef Server maps a given set of `policy_name` plus `policy_group` to
354
+ # a particular revision of a policy.
355
+
356
+ default :policy_name, nil
357
+ default :policy_group, nil
358
+
359
+ # Policyfiles can have multiple run lists, via the named run list feature.
360
+ # Generally this will be set by a CLI option via Chef::Application::Client,
361
+ # but it could be set in client.rb if desired.
362
+
363
+ default :named_run_list, nil
364
+
365
+ # During initial development, users were required to set `use_policyfile true`
366
+ # in `client.rb` to opt-in to policyfile use. Chef Client now examines
367
+ # configuration, node json, and the stored node to determine if policyfile
368
+ # usage is desired. This flag is still honored if set, but is unnecessary.
346
369
  default :use_policyfile, false
347
370
 
348
371
  # Policyfiles can be used in a native mode (default) or compatibility mode.
@@ -356,6 +379,16 @@ module ChefConfig
356
379
  # policyfiles with servers that don't yet support the native endpoints.
357
380
  default :policy_document_native_api, true
358
381
 
382
+ # When policyfiles are used in compatibility mode, `policy_name` and
383
+ # `policy_group` are instead specified using a combined configuration
384
+ # setting, `deployment_group`. For example, if policy_name should be
385
+ # "webserver" and policy_group should be "staging", then `deployment_group`
386
+ # should be set to "webserver-staging", which is the name of the data bag
387
+ # item that the policy will be stored as. NOTE: this setting only has an
388
+ # effect if `policy_document_native_api` is set to `false`.
389
+ default :deployment_group, nil
390
+
391
+
359
392
  # Set these to enable SSL authentication / mutual-authentication
360
393
  # with the server
361
394
 
@@ -657,6 +690,14 @@ module ChefConfig
657
690
  default :watchdog_timeout, 2 * (60 * 60) # 2 hours
658
691
  end
659
692
 
693
+ # Add an empty and non-strict config_context for chefdk. This lets the user
694
+ # have code like `chefdk.generator_cookbook "/path/to/cookbook"` in their
695
+ # config.rb, and it will be ignored by tools like knife and ohai. ChefDK
696
+ # itself can define the config options it accepts and enable strict mode,
697
+ # and that will only apply when running `chef` commands.
698
+ config_context :chefdk do
699
+ end
700
+
660
701
  # Chef requires an English-language UTF-8 locale to function properly. We attempt
661
702
  # to use the 'locale -a' command and search through a list of preferences until we
662
703
  # find one that we can use. On Ubuntu systems we should find 'C.UTF-8' and be
@@ -0,0 +1,223 @@
1
+ #
2
+ # Author:: Kartik Null Cating-Subramanian (<ksubramanian@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef, 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 'rake'
20
+ require 'rubygems'
21
+ require 'rubygems/package_task'
22
+
23
+ module ChefConfig
24
+ class PackageTask < Rake::TaskLib
25
+
26
+ # Full path to root of top-level repository. All other files (like VERSION or
27
+ # lib/<module_path>/version.rb are rooted at this path).
28
+ attr_accessor :root_path
29
+
30
+ # Name of the top-level module/library build built. This is used to define
31
+ # the top level module which contains VERSION and MODULE_ROOT.
32
+ attr_accessor :module_name
33
+
34
+ # Should the generated version.rb be in a class or module? Default is false (module).
35
+ attr_accessor :generate_version_class
36
+
37
+ # Paths to the roots of any components that also support ChefPackageTask.
38
+ # If relative paths are provided, they are rooted against root_path.
39
+ attr_accessor :component_paths
40
+
41
+ # This is the module name as it appears on the path "lib/module/".
42
+ # e.g. for module_name "ChefDK", you'd want module_path to be "chef-dk".
43
+ # The default is module_name but lower-cased.
44
+ attr_writer :module_path
45
+
46
+ def module_path
47
+ @module_path || module_name.downcase
48
+ end
49
+
50
+ # Path to a VERSION file with a single string that contains the package version.
51
+ # By default, this is root_path/VERSION
52
+ attr_accessor :version_file_path
53
+
54
+ # Directory used to store package files and output that is generated.
55
+ # This has the same meaning (or lack thereof) as package_dir in
56
+ # rake/packagetask.
57
+ attr_accessor :package_dir
58
+
59
+ # Name of git remote used to push tags during a release. Default is origin.
60
+ attr_accessor :git_remote
61
+
62
+ def initialize(root_path=nil, module_name=nil)
63
+ init(root_path, module_name)
64
+ yield self if block_given?
65
+ define unless root_path.nil? || module_name.nil?
66
+ end
67
+
68
+ def init(root_path, module_name)
69
+ @root_path = root_path
70
+ @module_name = module_name
71
+ @component_paths = []
72
+ @module_path = nil
73
+ @version_file_path = 'VERSION'
74
+ @package_dir = 'pkg'
75
+ @git_remote = 'origin'
76
+ @generate_version_class = false
77
+ end
78
+
79
+ def component_full_paths
80
+ component_paths.map { |path| File.expand_path(path, root_path)}
81
+ end
82
+
83
+ def version_rb_path
84
+ File.expand_path("lib/#{module_path}/version.rb", root_path)
85
+ end
86
+
87
+ def version
88
+ IO.read(File.expand_path(version_file_path, root_path)).strip
89
+ end
90
+
91
+ def full_package_dir
92
+ File.expand_path(package_dir, root_path)
93
+ end
94
+
95
+ def class_or_module
96
+ generate_version_class ? 'class' : 'module'
97
+ end
98
+
99
+ def with_clean_env(&block)
100
+ if defined?(Bundler)
101
+ Bundler.with_clean_env(&block)
102
+ else
103
+ block.call
104
+ end
105
+ end
106
+
107
+ def define
108
+ fail 'Need to provide package root and module name' if root_path.nil? || module_name.nil?
109
+
110
+ desc 'Build Gems of component dependencies'
111
+ task :package_components do
112
+ component_full_paths.each do |component_path|
113
+ Dir.chdir(component_path) do
114
+ sh 'rake package'
115
+ end
116
+ end
117
+ end
118
+
119
+ task :package => :package_components
120
+
121
+ desc 'Build and install component dependencies'
122
+ task :install_components => :package_components do
123
+ component_full_paths.each do |component_path|
124
+ Dir.chdir(component_path) do
125
+ sh 'rake install'
126
+ end
127
+ end
128
+ end
129
+
130
+ task :install => :install_components
131
+
132
+ desc 'Clean up builds of component dependencies'
133
+ task :clobber_component_packages do
134
+ component_full_paths.each do |component_path|
135
+ Dir.chdir(component_path) do
136
+ sh 'rake clobber_package'
137
+ end
138
+ end
139
+ end
140
+
141
+ task :clobber_package => :clobber_component_packages
142
+
143
+ desc 'Update the version number for component dependencies'
144
+ task :update_components_versions do
145
+ component_full_paths.each do |component_path|
146
+ Dir.chdir(component_path) do
147
+ sh 'rake version'
148
+ end
149
+ end
150
+ end
151
+
152
+ desc 'Regenerate lib/#{@module_path}/version.rb from VERSION file'
153
+ task :version => :update_components_versions do
154
+ contents = <<-VERSION_RB
155
+ # Copyright:: Copyright (c) 2010-2015 Chef Software, Inc.
156
+ # License:: Apache License, Version 2.0
157
+ #
158
+ # Licensed under the Apache License, Version 2.0 (the "License");
159
+ # you may not use this file except in compliance with the License.
160
+ # You may obtain a copy of the License at
161
+ #
162
+ # http://www.apache.org/licenses/LICENSE-2.0
163
+ #
164
+ # Unless required by applicable law or agreed to in writing, software
165
+ # distributed under the License is distributed on an "AS IS" BASIS,
166
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
167
+ # See the License for the specific language governing permissions and
168
+ # limitations under the License.
169
+
170
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
171
+ # NOTE: This file is generated by running `rake version` in the top level of
172
+ # this repo. Do not edit this manually. Edit the VERSION file and run the rake
173
+ # task instead.
174
+ #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
175
+
176
+ #{class_or_module} #{module_name}
177
+ #{module_name.upcase}_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
178
+ VERSION = '#{version}'
179
+ end
180
+
181
+ #
182
+ # NOTE: the Chef::Version class is defined in version_class.rb
183
+ #
184
+ # NOTE: DO NOT Use the Chef::Version class on #{module_name}::VERSIONs. The
185
+ # Chef::Version class is for _cookbooks_ only, and cannot handle
186
+ # pre-release versions like "10.14.0.rc.2". Please use Rubygem's
187
+ # Gem::Version class instead.
188
+ #
189
+ VERSION_RB
190
+ IO.write(version_rb_path, contents)
191
+ end
192
+
193
+ Dir[File.expand_path("*gemspec", root_path)].reverse.each do |gemspec_path|
194
+ gemspec = eval(IO.read(gemspec_path))
195
+ Gem::PackageTask.new(gemspec) do |task|
196
+ task.package_dir = full_package_dir
197
+ end
198
+ end
199
+
200
+ desc "Build and install a #{module_path} gem"
201
+ task :install => [:package] do
202
+ with_clean_env do
203
+ full_module_path = File.join(full_package_dir, module_path)
204
+ sh %{gem install #{full_module_path}-#{version}.gem --no-rdoc --no-ri}
205
+ end
206
+ end
207
+
208
+ task :uninstall do
209
+ sh %{gem uninstall #{module_path} -x -v #{version} }
210
+ end
211
+
212
+ desc 'Build it, tag it and ship it'
213
+ task :ship => [:clobber_package, :gem] do
214
+ sh("git tag #{version}")
215
+ sh("git push #{git_remote} --tags")
216
+ Dir[File.expand_path('*.gem', full_package_dir)].reverse.each do |built_gem|
217
+ sh("gem push #{built_gem}")
218
+ end
219
+ end
220
+ end
221
+ end
222
+
223
+ end
@@ -228,6 +228,37 @@ module ChefConfig
228
228
  joined_paths
229
229
  end
230
230
  end
231
+
232
+ # Determine if the given path is protected by OS X System Integrity Protection.
233
+ def self.is_sip_path?(path, node)
234
+ if node['platform'] == 'mac_os_x' and Gem::Version.new(node['platform_version']) >= Gem::Version.new('10.11')
235
+ # todo: parse rootless.conf for this?
236
+ sip_paths= [
237
+ '/System', '/bin', '/sbin', '/usr',
238
+ ]
239
+ sip_paths.each do |sip_path|
240
+ ChefConfig.logger.info("This is a SIP path, checking if it in exceptions list.")
241
+ return true if path.start_with?(sip_path)
242
+ end
243
+ false
244
+ else
245
+ false
246
+ end
247
+ end
248
+ # Determine if the given path is on the exception list for OS X System Integrity Protection.
249
+ def self.writable_sip_path?(path)
250
+ # todo: parse rootless.conf for this?
251
+ sip_exceptions = [
252
+ '/System/Library/Caches', '/System/Library/Extensions',
253
+ '/System/Library/Speech', '/System/Library/User Template',
254
+ '/usr/libexec/cups', '/usr/local', '/usr/share/man'
255
+ ]
256
+ sip_exceptions.each do |exception_path|
257
+ return true if path.start_with?(exception_path)
258
+ end
259
+ ChefConfig.logger.error("Cannot write to a SIP Path on OS X 10.11+")
260
+ false
261
+ end
231
262
  end
232
263
  end
233
264
 
@@ -20,6 +20,15 @@
20
20
  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21
21
 
22
22
  module ChefConfig
23
- VERSION = '12.5.0.alpha.1'
23
+ CHEFCONFIG_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
24
+ VERSION = '12.5.1'
24
25
  end
25
26
 
27
+ #
28
+ # NOTE: the Chef::Version class is defined in version_class.rb
29
+ #
30
+ # NOTE: DO NOT Use the Chef::Version class on ChefConfig::VERSIONs. The
31
+ # Chef::Version class is for _cookbooks_ only, and cannot handle
32
+ # pre-release versions like "10.14.0.rc.2". Please use Rubygem's
33
+ # Gem::Version class instead.
34
+ #
@@ -301,14 +301,36 @@ RSpec.describe ChefConfig::Config do
301
301
 
302
302
  describe "setting the config dir" do
303
303
 
304
+ context "when the config file is given with a relative path" do
305
+
306
+ before do
307
+ ChefConfig::Config.config_file = "client.rb"
308
+ end
309
+
310
+ it "expands the path when determining config_dir" do
311
+ # config_dir goes through PathHelper.canonical_path, which
312
+ # downcases on windows because the FS is case insensitive, so we
313
+ # have to downcase expected and actual to make the tests work.
314
+ expect(ChefConfig::Config.config_dir.downcase).to eq(to_platform(Dir.pwd).downcase)
315
+ end
316
+
317
+ it "does not set derived paths at FS root" do
318
+ ChefConfig::Config.local_mode = true
319
+ expect(ChefConfig::Config.cache_path.downcase).to eq(to_platform(File.join(Dir.pwd, 'local-mode-cache')).downcase)
320
+ end
321
+
322
+ end
323
+
304
324
  context "when the config file is /etc/chef/client.rb" do
305
325
 
306
326
  before do
307
- ChefConfig::Config.config_file = to_platform("/etc/chef/client.rb")
327
+ config_location = to_platform("/etc/chef/client.rb").downcase
328
+ allow(File).to receive(:absolute_path).with(config_location).and_return(config_location)
329
+ ChefConfig::Config.config_file = config_location
308
330
  end
309
331
 
310
332
  it "config_dir is /etc/chef" do
311
- expect(ChefConfig::Config.config_dir).to eq(to_platform("/etc/chef"))
333
+ expect(ChefConfig::Config.config_dir).to eq(to_platform("/etc/chef").downcase)
312
334
  end
313
335
 
314
336
  context "and chef is running in local mode" do
@@ -317,7 +339,7 @@ RSpec.describe ChefConfig::Config do
317
339
  end
318
340
 
319
341
  it "config_dir is /etc/chef" do
320
- expect(ChefConfig::Config.config_dir).to eq(to_platform("/etc/chef"))
342
+ expect(ChefConfig::Config.config_dir).to eq(to_platform("/etc/chef").downcase)
321
343
  end
322
344
  end
323
345
 
@@ -539,6 +561,14 @@ RSpec.describe ChefConfig::Config do
539
561
  end
540
562
  end
541
563
 
564
+ describe "allowing chefdk configuration outside of chefdk" do
565
+
566
+ it "allows arbitrary settings in the chefdk config context" do
567
+ expect { ChefConfig::Config.chefdk.generator_cookbook("/path") }.to_not raise_error
568
+ end
569
+
570
+ end
571
+
542
572
  describe "Treating deprecation warnings as errors" do
543
573
 
544
574
  context "when using our default RSpec configuration" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.5.0.alpha.1
4
+ version: 12.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-23 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -108,6 +108,7 @@ files:
108
108
  - lib/chef-config/config.rb
109
109
  - lib/chef-config/exceptions.rb
110
110
  - lib/chef-config/logger.rb
111
+ - lib/chef-config/package_task.rb
111
112
  - lib/chef-config/path_helper.rb
112
113
  - lib/chef-config/version.rb
113
114
  - lib/chef-config/windows.rb
@@ -131,12 +132,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
132
  version: '0'
132
133
  required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  requirements:
134
- - - ">"
135
+ - - ">="
135
136
  - !ruby/object:Gem::Version
136
- version: 1.3.1
137
+ version: '0'
137
138
  requirements: []
138
139
  rubyforge_project:
139
- rubygems_version: 2.4.4
140
+ rubygems_version: 2.4.5
140
141
  signing_key:
141
142
  specification_version: 4
142
143
  summary: Chef's default configuration and config loading