chef-config 12.4.0.rc.0
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 +7 -0
- data/LICENSE +201 -0
- data/README.md +4 -0
- data/Rakefile +55 -0
- data/lib/chef-config.rb +20 -0
- data/lib/chef-config/config.rb +744 -0
- data/lib/chef-config/exceptions.rb +26 -0
- data/lib/chef-config/logger.rb +62 -0
- data/lib/chef-config/path_helper.rb +233 -0
- data/lib/chef-config/version.rb +25 -0
- data/lib/chef-config/windows.rb +29 -0
- data/spec/spec_helper.rb +75 -0
- data/spec/unit/config_spec.rb +581 -0
- data/spec/unit/path_helper_spec.rb +291 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 47261ae6b047e19623d6d7a6ce2d6d591f0a6bcf
|
4
|
+
data.tar.gz: 6412fc7b6d5c90b1517b82362ccedf52542ff910
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1aeadc54e73f8e5f48d136f79a0cbf2d4d8d9d784557602f44a70918eceee7f26d9e95f62ba0872e729aa6beee7d99958a09f7fe457af52d9c66b8842497347
|
7
|
+
data.tar.gz: 387d9ee9742dde18cb99735ac2b8e2803442d4a5958ab0cc02e9080230e2b49e2a2e66b534dc8fc572704b13dda8f186c65efcd582084bc4f9e792a9264211ae
|
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'rubygems/package_task'
|
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
|
+
desc "Build and install a chef-config gem"
|
12
|
+
task :install => [:package] do
|
13
|
+
sh %{gem install pkg/chef-config-#{ChefConfig::VERSION}.gem --no-rdoc --no-ri}
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :spec
|
17
|
+
|
18
|
+
desc "Run standard specs"
|
19
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
20
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Regenerate lib/chef/version.rb from VERSION file"
|
24
|
+
task :version do
|
25
|
+
contents = <<-VERSION_RB
|
26
|
+
# Copyright:: Copyright (c) 2010-2015 Chef Software, Inc.
|
27
|
+
# License:: Apache License, Version 2.0
|
28
|
+
#
|
29
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
30
|
+
# you may not use this file except in compliance with the License.
|
31
|
+
# You may obtain a copy of the License at
|
32
|
+
#
|
33
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
34
|
+
#
|
35
|
+
# Unless required by applicable law or agreed to in writing, software
|
36
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
37
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
38
|
+
# See the License for the specific language governing permissions and
|
39
|
+
# limitations under the License.
|
40
|
+
|
41
|
+
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
42
|
+
# NOTE: This file is generated by running `rake version` in the top level of
|
43
|
+
# this repo. Do not edit this manually. Edit the VERSION file and run the rake
|
44
|
+
# task instead.
|
45
|
+
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
46
|
+
|
47
|
+
module ChefConfig
|
48
|
+
VERSION = '#{VERSION}'
|
49
|
+
end
|
50
|
+
|
51
|
+
VERSION_RB
|
52
|
+
version_rb_path = File.expand_path("../lib/chef-config/version.rb", __FILE__)
|
53
|
+
IO.write(version_rb_path, contents)
|
54
|
+
end
|
55
|
+
|
data/lib/chef-config.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2015 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
|
+
module ChefConfig
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,744 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Author:: AJ Christensen (<aj@opscode.com>)
|
5
|
+
# Author:: Mark Mzyk (<mmzyk@opscode.com>)
|
6
|
+
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
|
7
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
8
|
+
# License:: Apache License, Version 2.0
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at
|
13
|
+
#
|
14
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
#
|
16
|
+
# Unless required by applicable law or agreed to in writing, software
|
17
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
# See the License for the specific language governing permissions and
|
20
|
+
# limitations under the License.
|
21
|
+
|
22
|
+
require 'mixlib/config'
|
23
|
+
require 'pathname'
|
24
|
+
|
25
|
+
require 'chef-config/logger'
|
26
|
+
require 'chef-config/windows'
|
27
|
+
require 'chef-config/path_helper'
|
28
|
+
require 'mixlib/shellout'
|
29
|
+
|
30
|
+
module ChefConfig
|
31
|
+
|
32
|
+
class Config
|
33
|
+
|
34
|
+
extend Mixlib::Config
|
35
|
+
|
36
|
+
# Evaluates the given string as config.
|
37
|
+
#
|
38
|
+
# +filename+ is used for context in stacktraces, but doesn't need to be the name of an actual file.
|
39
|
+
def self.from_string(string, filename)
|
40
|
+
self.instance_eval(string, filename, 1)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.inspect
|
44
|
+
configuration.inspect
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.platform_specific_path(path)
|
48
|
+
path = PathHelper.cleanpath(path)
|
49
|
+
if ChefConfig.windows?
|
50
|
+
# turns \etc\chef\client.rb and \var\chef\client.rb into C:/chef/client.rb
|
51
|
+
if env['SYSTEMDRIVE'] && path[0] == '\\' && path.split('\\')[2] == 'chef'
|
52
|
+
path = PathHelper.join(env['SYSTEMDRIVE'], path.split('\\', 3)[2])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
path
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.add_formatter(name, file_path=nil)
|
59
|
+
formatters << [name, file_path]
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.add_event_logger(logger)
|
63
|
+
event_handlers << logger
|
64
|
+
end
|
65
|
+
|
66
|
+
# Config file to load (client.rb, knife.rb, etc. defaults set differently in knife, chef-client, etc.)
|
67
|
+
configurable(:config_file)
|
68
|
+
|
69
|
+
default(:config_dir) do
|
70
|
+
if config_file
|
71
|
+
PathHelper.dirname(config_file)
|
72
|
+
else
|
73
|
+
PathHelper.join(user_home, ".chef", "")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
default :formatters, []
|
78
|
+
|
79
|
+
# Override the config dispatch to set the value of multiple server options simultaneously
|
80
|
+
#
|
81
|
+
# === Parameters
|
82
|
+
# url<String>:: String to be set for all of the chef-server-api URL's
|
83
|
+
#
|
84
|
+
configurable(:chef_server_url).writes_value { |url| url.to_s.strip }
|
85
|
+
|
86
|
+
# When you are using ActiveSupport, they monkey-patch 'daemonize' into Kernel.
|
87
|
+
# So while this is basically identical to what method_missing would do, we pull
|
88
|
+
# it up here and get a real method written so that things get dispatched
|
89
|
+
# properly.
|
90
|
+
configurable(:daemonize).writes_value { |v| v }
|
91
|
+
|
92
|
+
# The root where all local chef object data is stored. cookbooks, data bags,
|
93
|
+
# environments are all assumed to be in separate directories under this.
|
94
|
+
# chef-solo uses these directories for input data. knife commands
|
95
|
+
# that upload or download files (such as knife upload, knife role from file,
|
96
|
+
# etc.) work.
|
97
|
+
default :chef_repo_path do
|
98
|
+
if self.configuration[:cookbook_path]
|
99
|
+
if self.configuration[:cookbook_path].kind_of?(String)
|
100
|
+
File.expand_path('..', self.configuration[:cookbook_path])
|
101
|
+
else
|
102
|
+
self.configuration[:cookbook_path].map do |path|
|
103
|
+
File.expand_path('..', path)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
else
|
107
|
+
cache_path
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.find_chef_repo_path(cwd)
|
112
|
+
# In local mode, we auto-discover the repo root by looking for a path with "cookbooks" under it.
|
113
|
+
# This allows us to run config-free.
|
114
|
+
path = cwd
|
115
|
+
until File.directory?(PathHelper.join(path, "cookbooks"))
|
116
|
+
new_path = File.expand_path('..', path)
|
117
|
+
if new_path == path
|
118
|
+
ChefConfig.logger.warn("No cookbooks directory found at or above current directory. Assuming #{Dir.pwd}.")
|
119
|
+
return Dir.pwd
|
120
|
+
end
|
121
|
+
path = new_path
|
122
|
+
end
|
123
|
+
ChefConfig.logger.info("Auto-discovered chef repository at #{path}")
|
124
|
+
path
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.derive_path_from_chef_repo_path(child_path)
|
128
|
+
if chef_repo_path.kind_of?(String)
|
129
|
+
PathHelper.join(chef_repo_path, child_path)
|
130
|
+
else
|
131
|
+
chef_repo_path.map { |path| PathHelper.join(path, child_path)}
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# Location of acls on disk. String or array of strings.
|
136
|
+
# Defaults to <chef_repo_path>/acls.
|
137
|
+
# Only applies to Enterprise Chef commands.
|
138
|
+
default(:acl_path) { derive_path_from_chef_repo_path('acls') }
|
139
|
+
|
140
|
+
# Location of clients on disk. String or array of strings.
|
141
|
+
# Defaults to <chef_repo_path>/acls.
|
142
|
+
default(:client_path) { derive_path_from_chef_repo_path('clients') }
|
143
|
+
|
144
|
+
# Location of cookbooks on disk. String or array of strings.
|
145
|
+
# Defaults to <chef_repo_path>/cookbooks. If chef_repo_path
|
146
|
+
# is not specified, this is set to [/var/chef/cookbooks, /var/chef/site-cookbooks]).
|
147
|
+
default(:cookbook_path) do
|
148
|
+
if self.configuration[:chef_repo_path]
|
149
|
+
derive_path_from_chef_repo_path('cookbooks')
|
150
|
+
else
|
151
|
+
Array(derive_path_from_chef_repo_path('cookbooks')).flatten +
|
152
|
+
Array(derive_path_from_chef_repo_path('site-cookbooks')).flatten
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Location of containers on disk. String or array of strings.
|
157
|
+
# Defaults to <chef_repo_path>/containers.
|
158
|
+
# Only applies to Enterprise Chef commands.
|
159
|
+
default(:container_path) { derive_path_from_chef_repo_path('containers') }
|
160
|
+
|
161
|
+
# Location of data bags on disk. String or array of strings.
|
162
|
+
# Defaults to <chef_repo_path>/data_bags.
|
163
|
+
default(:data_bag_path) { derive_path_from_chef_repo_path('data_bags') }
|
164
|
+
|
165
|
+
# Location of environments on disk. String or array of strings.
|
166
|
+
# Defaults to <chef_repo_path>/environments.
|
167
|
+
default(:environment_path) { derive_path_from_chef_repo_path('environments') }
|
168
|
+
|
169
|
+
# Location of groups on disk. String or array of strings.
|
170
|
+
# Defaults to <chef_repo_path>/groups.
|
171
|
+
# Only applies to Enterprise Chef commands.
|
172
|
+
default(:group_path) { derive_path_from_chef_repo_path('groups') }
|
173
|
+
|
174
|
+
# Location of nodes on disk. String or array of strings.
|
175
|
+
# Defaults to <chef_repo_path>/nodes.
|
176
|
+
default(:node_path) { derive_path_from_chef_repo_path('nodes') }
|
177
|
+
|
178
|
+
# Location of roles on disk. String or array of strings.
|
179
|
+
# Defaults to <chef_repo_path>/roles.
|
180
|
+
default(:role_path) { derive_path_from_chef_repo_path('roles') }
|
181
|
+
|
182
|
+
# Location of users on disk. String or array of strings.
|
183
|
+
# Defaults to <chef_repo_path>/users.
|
184
|
+
# Does not apply to Enterprise Chef commands.
|
185
|
+
default(:user_path) { derive_path_from_chef_repo_path('users') }
|
186
|
+
|
187
|
+
# Location of policies on disk. String or array of strings.
|
188
|
+
# Defaults to <chef_repo_path>/policies.
|
189
|
+
default(:policy_path) { derive_path_from_chef_repo_path('policies') }
|
190
|
+
|
191
|
+
# Turn on "path sanity" by default. See also: http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity
|
192
|
+
default :enforce_path_sanity, true
|
193
|
+
|
194
|
+
# Formatted Chef Client output is a beta feature, disabled by default:
|
195
|
+
default :formatter, "null"
|
196
|
+
|
197
|
+
# The number of times the client should retry when registering with the server
|
198
|
+
default :client_registration_retries, 5
|
199
|
+
|
200
|
+
# An array of paths to search for knife exec scripts if they aren't in the current directory
|
201
|
+
default :script_path, []
|
202
|
+
|
203
|
+
# The root of all caches (checksums, cache and backup). If local mode is on,
|
204
|
+
# this is under the user's home directory.
|
205
|
+
default(:cache_path) do
|
206
|
+
if local_mode
|
207
|
+
PathHelper.join(config_dir, 'local-mode-cache')
|
208
|
+
else
|
209
|
+
primary_cache_root = platform_specific_path("/var")
|
210
|
+
primary_cache_path = platform_specific_path("/var/chef")
|
211
|
+
# Use /var/chef as the cache path only if that folder exists and we can read and write
|
212
|
+
# into it, or /var exists and we can read and write into it (we'll create /var/chef later).
|
213
|
+
# Otherwise, we'll create .chef under the user's home directory and use that as
|
214
|
+
# the cache path.
|
215
|
+
unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root)
|
216
|
+
secondary_cache_path = PathHelper.join(user_home, '.chef')
|
217
|
+
ChefConfig.logger.info("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
|
218
|
+
secondary_cache_path
|
219
|
+
else
|
220
|
+
primary_cache_path
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns true only if the path exists and is readable and writeable for the user.
|
226
|
+
def self.path_accessible?(path)
|
227
|
+
File.exists?(path) && File.readable?(path) && File.writable?(path)
|
228
|
+
end
|
229
|
+
|
230
|
+
# Where cookbook files are stored on the server (by content checksum)
|
231
|
+
default(:checksum_path) { PathHelper.join(cache_path, "checksums") }
|
232
|
+
|
233
|
+
# Where chef's cache files should be stored
|
234
|
+
default(:file_cache_path) { PathHelper.join(cache_path, "cache") }
|
235
|
+
|
236
|
+
# Where backups of chef-managed files should go
|
237
|
+
default(:file_backup_path) { PathHelper.join(cache_path, "backup") }
|
238
|
+
|
239
|
+
# The chef-client (or solo) lockfile.
|
240
|
+
#
|
241
|
+
# If your `file_cache_path` resides on a NFS (or non-flock()-supporting
|
242
|
+
# fs), it's recommended to set this to something like
|
243
|
+
# '/tmp/chef-client-running.pid'
|
244
|
+
default(:lockfile) { PathHelper.join(file_cache_path, "chef-client-running.pid") }
|
245
|
+
|
246
|
+
## Daemonization Settings ##
|
247
|
+
# What user should Chef run as?
|
248
|
+
default :user, nil
|
249
|
+
default :group, nil
|
250
|
+
default :umask, 0022
|
251
|
+
|
252
|
+
# Valid log_levels are:
|
253
|
+
# * :debug
|
254
|
+
# * :info
|
255
|
+
# * :warn
|
256
|
+
# * :fatal
|
257
|
+
# These work as you'd expect. There is also a special `:auto` setting.
|
258
|
+
# When set to :auto, Chef will auto adjust the log verbosity based on
|
259
|
+
# context. When a tty is available (usually because the user is running chef
|
260
|
+
# in a console), the log level is set to :warn, and output formatters are
|
261
|
+
# used as the primary mode of output. When a tty is not available, the
|
262
|
+
# logger is the primary mode of output, and the log level is set to :info
|
263
|
+
default :log_level, :auto
|
264
|
+
|
265
|
+
# Logging location as either an IO stream or string representing log file path
|
266
|
+
default :log_location, STDOUT
|
267
|
+
|
268
|
+
# Using `force_formatter` causes chef to default to formatter output when STDOUT is not a tty
|
269
|
+
default :force_formatter, false
|
270
|
+
|
271
|
+
# Using `force_logger` causes chef to default to logger output when STDOUT is a tty
|
272
|
+
default :force_logger, false
|
273
|
+
|
274
|
+
default :http_retry_count, 5
|
275
|
+
default :http_retry_delay, 5
|
276
|
+
default :interval, nil
|
277
|
+
default :once, nil
|
278
|
+
default :json_attribs, nil
|
279
|
+
# toggle info level log items that can create a lot of output
|
280
|
+
default :verbose_logging, true
|
281
|
+
default :node_name, nil
|
282
|
+
default :diff_disabled, false
|
283
|
+
default :diff_filesize_threshold, 10000000
|
284
|
+
default :diff_output_threshold, 1000000
|
285
|
+
default :local_mode, false
|
286
|
+
|
287
|
+
default :pid_file, nil
|
288
|
+
|
289
|
+
# Whether Chef Zero local mode should bind to a port. All internal requests
|
290
|
+
# will go through the socketless code path regardless, so the socket is
|
291
|
+
# only needed if other processes will connect to the local mode server.
|
292
|
+
#
|
293
|
+
# For compatibility this is set to true but it will be changed to false in
|
294
|
+
# the future.
|
295
|
+
default :listen, true
|
296
|
+
|
297
|
+
config_context :chef_zero do
|
298
|
+
config_strict_mode true
|
299
|
+
default(:enabled) { ChefConfig::Config.local_mode }
|
300
|
+
default :host, 'localhost'
|
301
|
+
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
|
302
|
+
end
|
303
|
+
default :chef_server_url, "https://localhost:443"
|
304
|
+
|
305
|
+
default(:chef_server_root) do
|
306
|
+
# if the chef_server_url is a path to an organization, aka
|
307
|
+
# 'some_url.../organizations/*' then remove the '/organization/*' by default
|
308
|
+
if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/
|
309
|
+
self.configuration[:chef_server_url].split('/')[0..-3].join('/')
|
310
|
+
elsif self.configuration[:chef_server_url] # default to whatever chef_server_url is
|
311
|
+
self.configuration[:chef_server_url]
|
312
|
+
else
|
313
|
+
"https://localhost:443"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
default :rest_timeout, 300
|
318
|
+
default :yum_timeout, 900
|
319
|
+
default :yum_lock_timeout, 30
|
320
|
+
default :solo, false
|
321
|
+
default :splay, nil
|
322
|
+
default :why_run, false
|
323
|
+
default :color, false
|
324
|
+
default :client_fork, true
|
325
|
+
default :ez, false
|
326
|
+
default :enable_reporting, true
|
327
|
+
default :enable_reporting_url_fatals, false
|
328
|
+
# Possible values for :audit_mode
|
329
|
+
# :enabled, :disabled, :audit_only,
|
330
|
+
#
|
331
|
+
# TODO: 11 Dec 2014: Currently audit-mode is an experimental feature
|
332
|
+
# and is disabled by default. When users choose to enable audit-mode,
|
333
|
+
# a warning is issued in application/client#reconfigure.
|
334
|
+
# This can be removed when audit-mode is enabled by default.
|
335
|
+
default :audit_mode, :disabled
|
336
|
+
|
337
|
+
# Chef only needs ohai to run the hostname plugin for the most basic
|
338
|
+
# functionality. If the rest of the ohai plugins are not needed (like in
|
339
|
+
# most of our testing scenarios)
|
340
|
+
default :minimal_ohai, false
|
341
|
+
|
342
|
+
# Policyfile is a feature where a node gets its run list and cookbook
|
343
|
+
# version set from a single document on the server instead of expanding the
|
344
|
+
# run list and having the server compute the cookbook version set based on
|
345
|
+
# environment constraints.
|
346
|
+
default :use_policyfile, false
|
347
|
+
|
348
|
+
# Policyfiles can be used in a native mode (default) or compatibility mode.
|
349
|
+
# Native mode requires Chef Server 12.1 (it can be enabled via feature flag
|
350
|
+
# on some prior versions). In native mode, policies and associated
|
351
|
+
# cookbooks are accessed via feature-specific APIs. In compat mode,
|
352
|
+
# policies are stored as data bags and cookbooks are stored at the
|
353
|
+
# cookbooks/ endpoint. Compatibility mode can be dangerous on existing Chef
|
354
|
+
# Servers; it's recommended to upgrade your Chef Server rather than use
|
355
|
+
# compatibility mode. Compatibility mode remains available so you can use
|
356
|
+
# policyfiles with servers that don't yet support the native endpoints.
|
357
|
+
default :policy_document_native_api, true
|
358
|
+
|
359
|
+
# Set these to enable SSL authentication / mutual-authentication
|
360
|
+
# with the server
|
361
|
+
|
362
|
+
# Client side SSL cert/key for mutual auth
|
363
|
+
default :ssl_client_cert, nil
|
364
|
+
default :ssl_client_key, nil
|
365
|
+
|
366
|
+
# Whether or not to verify the SSL cert for all HTTPS requests. When set to
|
367
|
+
# :verify_peer (default), all HTTPS requests will be validated regardless of other
|
368
|
+
# SSL verification settings. When set to :verify_none no HTTPS requests will
|
369
|
+
# be validated.
|
370
|
+
default :ssl_verify_mode, :verify_peer
|
371
|
+
|
372
|
+
# Whether or not to verify the SSL cert for HTTPS requests to the Chef
|
373
|
+
# server API. If set to `true`, the server's cert will be validated
|
374
|
+
# regardless of the :ssl_verify_mode setting. This is set to `true` when
|
375
|
+
# running in local-mode.
|
376
|
+
# NOTE: This is a workaround until verify_peer is enabled by default.
|
377
|
+
default(:verify_api_cert) { ChefConfig::Config.local_mode }
|
378
|
+
|
379
|
+
# Path to the default CA bundle files.
|
380
|
+
default :ssl_ca_path, nil
|
381
|
+
default(:ssl_ca_file) do
|
382
|
+
if ChefConfig.windows? and embedded_path = embedded_dir
|
383
|
+
cacert_path = File.join(embedded_path, "ssl/certs/cacert.pem")
|
384
|
+
cacert_path if File.exist?(cacert_path)
|
385
|
+
else
|
386
|
+
nil
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
# A directory that contains additional SSL certificates to trust. Any
|
391
|
+
# certificates in this directory will be added to whatever CA bundle ruby
|
392
|
+
# is using. Use this to add self-signed certs for your Chef Server or local
|
393
|
+
# HTTP file servers.
|
394
|
+
default(:trusted_certs_dir) { PathHelper.join(config_dir, "trusted_certs") }
|
395
|
+
|
396
|
+
# Where should chef-solo download recipes from?
|
397
|
+
default :recipe_url, nil
|
398
|
+
|
399
|
+
# Sets the version of the signed header authentication protocol to use (see
|
400
|
+
# the 'mixlib-authorization' project for more detail). Currently, versions
|
401
|
+
# 1.0 and 1.1 are available; however, the chef-server must first be
|
402
|
+
# upgraded to support version 1.1 before clients can begin using it.
|
403
|
+
#
|
404
|
+
# Version 1.1 of the protocol is required when using a `node_name` greater
|
405
|
+
# than ~90 bytes (~90 ascii characters), so chef-client will automatically
|
406
|
+
# switch to using version 1.1 when `node_name` is too large for the 1.0
|
407
|
+
# protocol. If you intend to use large node names, ensure that your server
|
408
|
+
# supports version 1.1. Automatic detection of large node names means that
|
409
|
+
# users will generally not need to manually configure this.
|
410
|
+
#
|
411
|
+
# In the future, this configuration option may be replaced with an
|
412
|
+
# automatic negotiation scheme.
|
413
|
+
default :authentication_protocol_version, "1.0"
|
414
|
+
|
415
|
+
# This key will be used to sign requests to the Chef server. This location
|
416
|
+
# must be writable by Chef during initial setup when generating a client
|
417
|
+
# identity on the server.
|
418
|
+
#
|
419
|
+
# The chef-server will look up the public key for the client using the
|
420
|
+
# `node_name` of the client.
|
421
|
+
#
|
422
|
+
# If chef-zero is enabled, this defaults to nil (no authentication).
|
423
|
+
default(:client_key) { chef_zero.enabled ? nil : platform_specific_path("/etc/chef/client.pem") }
|
424
|
+
|
425
|
+
# When registering the client, should we allow the client key location to
|
426
|
+
# be a symlink? eg: /etc/chef/client.pem -> /etc/chef/prod-client.pem
|
427
|
+
# If the path of the key goes through a directory like /tmp this should
|
428
|
+
# never be set to true or its possibly an easily exploitable security hole.
|
429
|
+
default :follow_client_key_symlink, false
|
430
|
+
|
431
|
+
# This secret is used to decrypt encrypted data bag items.
|
432
|
+
default(:encrypted_data_bag_secret) do
|
433
|
+
if File.exist?(platform_specific_path("/etc/chef/encrypted_data_bag_secret"))
|
434
|
+
platform_specific_path("/etc/chef/encrypted_data_bag_secret")
|
435
|
+
else
|
436
|
+
nil
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|
440
|
+
# As of Chef 11.0, version "1" is the default encrypted data bag item
|
441
|
+
# format. Version "2" is available which adds encrypt-then-mac protection.
|
442
|
+
# To maintain compatibility, versions other than 1 must be opt-in.
|
443
|
+
#
|
444
|
+
# Set this to `2` if you have chef-client 11.6.0+ in your infrastructure.
|
445
|
+
# Set this to `3` if you have chef-client 11.?.0+, ruby 2 and OpenSSL >= 1.0.1 in your infrastructure. (TODO)
|
446
|
+
default :data_bag_encrypt_version, 1
|
447
|
+
|
448
|
+
# When reading data bag items, any supported version is accepted. However,
|
449
|
+
# if all encrypted data bags have been generated with the version 2 format,
|
450
|
+
# it is recommended to disable support for earlier formats to improve
|
451
|
+
# security. For example, the version 2 format is identical to version 1
|
452
|
+
# except for the addition of an HMAC, so an attacker with MITM capability
|
453
|
+
# could downgrade an encrypted data bag to version 1 as part of an attack.
|
454
|
+
default :data_bag_decrypt_minimum_version, 0
|
455
|
+
|
456
|
+
# If there is no file in the location given by `client_key`, chef-client
|
457
|
+
# will temporarily use the "validator" identity to generate one. If the
|
458
|
+
# `client_key` is not present and the `validation_key` is also not present,
|
459
|
+
# chef-client will not be able to authenticate to the server.
|
460
|
+
#
|
461
|
+
# The `validation_key` is never used if the `client_key` exists.
|
462
|
+
#
|
463
|
+
# If chef-zero is enabled, this defaults to nil (no authentication).
|
464
|
+
default(:validation_key) { chef_zero.enabled ? nil : platform_specific_path("/etc/chef/validation.pem") }
|
465
|
+
default :validation_client_name, "chef-validator"
|
466
|
+
|
467
|
+
# When creating a new client via the validation_client account, Chef 11
|
468
|
+
# servers allow the client to generate a key pair locally and send the
|
469
|
+
# public key to the server. This is more secure and helps offload work from
|
470
|
+
# the server, enhancing scalability. If enabled and the remote server
|
471
|
+
# implements only the Chef 10 API, client registration will not work
|
472
|
+
# properly.
|
473
|
+
#
|
474
|
+
# The default value is `true`. Set to `false` to disable client-side key
|
475
|
+
# generation (server generates client keys).
|
476
|
+
default(:local_key_generation) { true }
|
477
|
+
|
478
|
+
# Zypper package provider gpg checks. Set to true to enable package
|
479
|
+
# gpg signature checking. This will be default in the
|
480
|
+
# future. Setting to false disables the warnings.
|
481
|
+
# Leaving this set to nil or false is a security hazard!
|
482
|
+
default :zypper_check_gpg, nil
|
483
|
+
|
484
|
+
# Report Handlers
|
485
|
+
default :report_handlers, []
|
486
|
+
|
487
|
+
# Event Handlers
|
488
|
+
default :event_handlers, []
|
489
|
+
|
490
|
+
default :disable_event_loggers, false
|
491
|
+
|
492
|
+
# Exception Handlers
|
493
|
+
default :exception_handlers, []
|
494
|
+
|
495
|
+
# Start handlers
|
496
|
+
default :start_handlers, []
|
497
|
+
|
498
|
+
# Syntax Check Cache. Knife keeps track of files that is has already syntax
|
499
|
+
# checked by storing files in this directory. `syntax_check_cache_path` is
|
500
|
+
# the new (and preferred) configuration setting. If not set, knife will
|
501
|
+
# fall back to using cache_options[:path], which is deprecated but exists in
|
502
|
+
# many client configs generated by pre-Chef-11 bootstrappers.
|
503
|
+
default(:syntax_check_cache_path) { cache_options[:path] }
|
504
|
+
|
505
|
+
# Deprecated:
|
506
|
+
# Move this to the default value of syntax_cache_path when this is removed.
|
507
|
+
default(:cache_options) { { :path => PathHelper.join(config_dir, "syntaxcache") } }
|
508
|
+
|
509
|
+
# Whether errors should be raised for deprecation warnings. When set to
|
510
|
+
# `false` (the default setting), a warning is emitted but code using
|
511
|
+
# deprecated methods/features/etc. should work normally otherwise. When set
|
512
|
+
# to `true`, usage of deprecated methods/features will raise a
|
513
|
+
# `DeprecatedFeatureError`. This is used by Chef's tests to ensure that
|
514
|
+
# deprecated functionality is not used internally by Chef. End users
|
515
|
+
# should generally leave this at the default setting (especially in
|
516
|
+
# production), but it may be useful when testing cookbooks or other code if
|
517
|
+
# the user wishes to aggressively address deprecations.
|
518
|
+
default(:treat_deprecation_warnings_as_errors) do
|
519
|
+
# Using an environment variable allows this setting to be inherited in
|
520
|
+
# tests that spawn new processes.
|
521
|
+
ENV.key?("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
|
522
|
+
end
|
523
|
+
|
524
|
+
# knife configuration data
|
525
|
+
config_context :knife do
|
526
|
+
default :ssh_port, nil
|
527
|
+
default :ssh_user, nil
|
528
|
+
default :ssh_attribute, nil
|
529
|
+
default :ssh_gateway, nil
|
530
|
+
default :bootstrap_version, nil
|
531
|
+
default :bootstrap_proxy, nil
|
532
|
+
default :bootstrap_template, nil
|
533
|
+
default :secret, nil
|
534
|
+
default :secret_file, nil
|
535
|
+
default :identity_file, nil
|
536
|
+
default :host_key_verify, nil
|
537
|
+
default :forward_agent, nil
|
538
|
+
default :sort_status_reverse, nil
|
539
|
+
default :hints, {}
|
540
|
+
end
|
541
|
+
|
542
|
+
def self.set_defaults_for_windows
|
543
|
+
# Those lists of regular expressions define what chef considers a
|
544
|
+
# valid user and group name
|
545
|
+
# From http://technet.microsoft.com/en-us/library/cc776019(WS.10).aspx
|
546
|
+
principal_valid_regex_part = '[^"\/\\\\\[\]\:;|=,+*?<>]+'
|
547
|
+
default :user_valid_regex, [ /^(#{principal_valid_regex_part}\\)?#{principal_valid_regex_part}$/ ]
|
548
|
+
default :group_valid_regex, [ /^(#{principal_valid_regex_part}\\)?#{principal_valid_regex_part}$/ ]
|
549
|
+
|
550
|
+
default :fatal_windows_admin_check, false
|
551
|
+
end
|
552
|
+
|
553
|
+
def self.set_defaults_for_nix
|
554
|
+
# Those lists of regular expressions define what chef considers a
|
555
|
+
# valid user and group name
|
556
|
+
#
|
557
|
+
# user/group cannot start with '-', '+' or '~'
|
558
|
+
# user/group cannot contain ':', ',' or non-space-whitespace or null byte
|
559
|
+
# everything else is allowed (UTF-8, spaces, etc) and we delegate to your O/S useradd program to barf or not
|
560
|
+
# copies: http://anonscm.debian.org/viewvc/pkg-shadow/debian/trunk/debian/patches/506_relaxed_usernames?view=markup
|
561
|
+
default :user_valid_regex, [ /^[^-+~:,\t\r\n\f\0]+[^:,\t\r\n\f\0]*$/ ]
|
562
|
+
default :group_valid_regex, [ /^[^-+~:,\t\r\n\f\0]+[^:,\t\r\n\f\0]*$/ ]
|
563
|
+
end
|
564
|
+
|
565
|
+
# Those lists of regular expressions define what chef considers a
|
566
|
+
# valid user and group name
|
567
|
+
if ChefConfig.windows?
|
568
|
+
set_defaults_for_windows
|
569
|
+
else
|
570
|
+
set_defaults_for_nix
|
571
|
+
end
|
572
|
+
|
573
|
+
# This provides a hook which rspec can stub so that we can avoid twiddling
|
574
|
+
# global state in tests.
|
575
|
+
def self.env
|
576
|
+
ENV
|
577
|
+
end
|
578
|
+
|
579
|
+
def self.windows_home_path
|
580
|
+
ChefConfig.logger.deprecation("Chef::Config.windows_home_path is now deprecated. Consider using Chef::Util::PathHelper.home instead.")
|
581
|
+
PathHelper.home
|
582
|
+
end
|
583
|
+
|
584
|
+
# returns a platform specific path to the user home dir if set, otherwise default to current directory.
|
585
|
+
default( :user_home ) { PathHelper.home || Dir.pwd }
|
586
|
+
|
587
|
+
# Enable file permission fixup for selinux. Fixup will be done
|
588
|
+
# only if selinux is enabled in the system.
|
589
|
+
default :enable_selinux_file_permission_fixup, true
|
590
|
+
|
591
|
+
# Use atomic updates (i.e. move operation) while updating contents
|
592
|
+
# of the files resources. When set to false copy operation is
|
593
|
+
# used to update files.
|
594
|
+
default :file_atomic_update, true
|
595
|
+
|
596
|
+
# There are 3 possible values for this configuration setting.
|
597
|
+
# true => file staging is done in the destination directory
|
598
|
+
# false => file staging is done via tempfiles under ENV['TMP']
|
599
|
+
# :auto => file staging will try using destination directory if possible and
|
600
|
+
# will fall back to ENV['TMP'] if destination directory is not usable.
|
601
|
+
default :file_staging_uses_destdir, :auto
|
602
|
+
|
603
|
+
# Exit if another run is in progress and the chef-client is unable to
|
604
|
+
# get the lock before time expires. If nil, no timeout is enforced. (Exits
|
605
|
+
# immediately if 0.)
|
606
|
+
default :run_lock_timeout, nil
|
607
|
+
|
608
|
+
# Number of worker threads for syncing cookbooks in parallel. Increasing
|
609
|
+
# this number can result in gateway errors from the server (namely 503 and 504).
|
610
|
+
# If you are seeing this behavior while using the default setting, reducing
|
611
|
+
# the number of threads will help.
|
612
|
+
default :cookbook_sync_threads, 10
|
613
|
+
|
614
|
+
# At the beginning of the Chef Client run, the cookbook manifests are downloaded which
|
615
|
+
# contain URLs for every file in every relevant cookbook. Most of the files
|
616
|
+
# (recipes, resources, providers, libraries, etc) are immediately synchronized
|
617
|
+
# at the start of the run. The handling of "files" and "templates" directories,
|
618
|
+
# however, have two modes of operation. They can either all be downloaded immediately
|
619
|
+
# at the start of the run (no_lazy_load==true) or else they can be lazily loaded as
|
620
|
+
# cookbook_file or template resources are converged which require them (no_lazy_load==false).
|
621
|
+
#
|
622
|
+
# The advantage of lazily loading these files is that unnecessary files are not
|
623
|
+
# synchronized. This may be useful to users with large files checked into cookbooks which
|
624
|
+
# are only selectively downloaded to a subset of clients which use the cookbook. However,
|
625
|
+
# better solutions are to either isolate large files into individual cookbooks and only
|
626
|
+
# include those cookbooks in the run lists of the servers that need them -- or move to
|
627
|
+
# using remote_file and a more appropriate backing store like S3 for large file
|
628
|
+
# distribution.
|
629
|
+
#
|
630
|
+
# The disadvantages of lazily loading files are that users some time find it
|
631
|
+
# confusing that their cookbooks are not fully synchronzied to the cache initially,
|
632
|
+
# and more importantly the time-sensitive URLs which are in the manifest may time
|
633
|
+
# out on long Chef runs before the resource that uses the file is converged
|
634
|
+
# (leading to many confusing 403 errors on template/cookbook_file resources).
|
635
|
+
#
|
636
|
+
default :no_lazy_load, true
|
637
|
+
|
638
|
+
# Default for the chef_gem compile_time attribute. Nil is the same as true but will emit
|
639
|
+
# warnings on every use of chef_gem prompting the user to be explicit. If the user sets this to
|
640
|
+
# true then the user will get backcompat behavior but with a single nag warning that cookbooks
|
641
|
+
# may break with this setting in the future. The false setting is the recommended setting and
|
642
|
+
# will become the default.
|
643
|
+
default :chef_gem_compile_time, nil
|
644
|
+
|
645
|
+
# A whitelisted array of attributes you want sent over the wire when node
|
646
|
+
# data is saved.
|
647
|
+
# The default setting is nil, which collects all data. Setting to [] will not
|
648
|
+
# collect any data for save.
|
649
|
+
default :automatic_attribute_whitelist, nil
|
650
|
+
default :default_attribute_whitelist, nil
|
651
|
+
default :normal_attribute_whitelist, nil
|
652
|
+
default :override_attribute_whitelist, nil
|
653
|
+
|
654
|
+
config_context :windows_service do
|
655
|
+
# Set `watchdog_timeout` to the number of seconds to wait for a chef-client run
|
656
|
+
# to finish
|
657
|
+
default :watchdog_timeout, 2 * (60 * 60) # 2 hours
|
658
|
+
end
|
659
|
+
|
660
|
+
# Chef requires an English-language UTF-8 locale to function properly. We attempt
|
661
|
+
# to use the 'locale -a' command and search through a list of preferences until we
|
662
|
+
# find one that we can use. On Ubuntu systems we should find 'C.UTF-8' and be
|
663
|
+
# able to use that even if there is no English locale on the server, but Mac, Solaris,
|
664
|
+
# AIX, etc do not have that locale. We then try to find an English locale and fall
|
665
|
+
# back to 'C' if we do not. The choice of fallback is pick-your-poison. If we try
|
666
|
+
# to do the work to return a non-US UTF-8 locale then we fail inside of providers when
|
667
|
+
# things like 'svn info' return Japanese and we can't parse them. OTOH, if we pick 'C' then
|
668
|
+
# we will blow up on UTF-8 characters. Between the warn we throw and the Encoding
|
669
|
+
# exception that ruby will throw it is more obvious what is broken if we drop UTF-8 by
|
670
|
+
# default rather than drop English.
|
671
|
+
#
|
672
|
+
# If there is no 'locale -a' then we return 'en_US.UTF-8' since that is the most commonly
|
673
|
+
# available English UTF-8 locale. However, all modern POSIXen should support 'locale -a'.
|
674
|
+
def self.guess_internal_locale
|
675
|
+
# https://github.com/opscode/chef/issues/2181
|
676
|
+
# Some systems have the `locale -a` command, but the result has
|
677
|
+
# invalid characters for the default encoding.
|
678
|
+
#
|
679
|
+
# For example, on CentOS 6 with ENV['LANG'] = "en_US.UTF-8",
|
680
|
+
# `locale -a`.split fails with ArgumentError invalid UTF-8 encoding.
|
681
|
+
cmd = Mixlib::ShellOut.new("locale -a").run_command
|
682
|
+
cmd.error!
|
683
|
+
locales = cmd.stdout.split
|
684
|
+
case
|
685
|
+
when locales.include?('C.UTF-8')
|
686
|
+
'C.UTF-8'
|
687
|
+
when locales.include?('en_US.UTF-8'), locales.include?('en_US.utf8')
|
688
|
+
'en_US.UTF-8'
|
689
|
+
when locales.include?('en.UTF-8')
|
690
|
+
'en.UTF-8'
|
691
|
+
else
|
692
|
+
# Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8
|
693
|
+
guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i }
|
694
|
+
unless guesses.empty?
|
695
|
+
guessed_locale = guesses.first
|
696
|
+
# Transform into the form en_ZZ.UTF-8
|
697
|
+
guessed_locale.gsub(/UTF-?8$/i, "UTF-8")
|
698
|
+
else
|
699
|
+
ChefConfig.logger.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support."
|
700
|
+
'C'
|
701
|
+
end
|
702
|
+
end
|
703
|
+
rescue
|
704
|
+
if ChefConfig.windows?
|
705
|
+
ChefConfig.logger.debug "Defaulting to locale en_US.UTF-8 on Windows, until it matters that we do something else."
|
706
|
+
else
|
707
|
+
ChefConfig.logger.debug "No usable locale -a command found, assuming you have en_US.UTF-8 installed."
|
708
|
+
end
|
709
|
+
'en_US.UTF-8'
|
710
|
+
end
|
711
|
+
|
712
|
+
default :internal_locale, guess_internal_locale
|
713
|
+
|
714
|
+
# Force UTF-8 Encoding, for when we fire up in the 'C' locale or other strange locales (e.g.
|
715
|
+
# japanese windows encodings). If we do not do this, then knife upload will fail when a cookbook's
|
716
|
+
# README.md has UTF-8 characters that do not encode in whatever surrounding encoding we have been
|
717
|
+
# passed. Effectively, the Chef Ecosystem is globally UTF-8 by default. Anyone who wants to be
|
718
|
+
# able to upload Shift_JIS or ISO-8859-1 files needs to mark *those* files explicitly with
|
719
|
+
# magic tags to make ruby correctly identify the encoding being used. Changing this default will
|
720
|
+
# break Chef community cookbooks and is very highly discouraged.
|
721
|
+
default :ruby_encoding, Encoding::UTF_8
|
722
|
+
|
723
|
+
# If installed via an omnibus installer, this gives the path to the
|
724
|
+
# "embedded" directory which contains all of the software packaged with
|
725
|
+
# omnibus. This is used to locate the cacert.pem file on windows.
|
726
|
+
def self.embedded_dir
|
727
|
+
Pathname.new(_this_file).ascend do |path|
|
728
|
+
if path.basename.to_s == "embedded"
|
729
|
+
return path.to_s
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
nil
|
734
|
+
end
|
735
|
+
|
736
|
+
# Path to this file in the current install.
|
737
|
+
def self._this_file
|
738
|
+
File.expand_path(__FILE__)
|
739
|
+
end
|
740
|
+
end
|
741
|
+
end
|
742
|
+
|
743
|
+
|
744
|
+
|