chef 12.3.0 → 12.4.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +86 -7
- data/distro/common/markdown/man1/chef-shell.mkd +4 -4
- data/distro/common/markdown/man1/knife-bootstrap.mkd +1 -1
- data/distro/common/markdown/man1/knife-client.mkd +1 -1
- data/distro/common/markdown/man1/knife-configure.mkd +1 -1
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +1 -1
- data/distro/common/markdown/man1/knife-cookbook.mkd +4 -4
- data/distro/common/markdown/man1/knife-data-bag.mkd +1 -1
- data/distro/common/markdown/man1/knife-environment.mkd +3 -3
- data/distro/common/markdown/man1/knife-exec.mkd +1 -1
- data/distro/common/markdown/man1/knife-index.mkd +1 -1
- data/distro/common/markdown/man1/knife-node.mkd +1 -1
- data/distro/common/markdown/man1/knife-role.mkd +3 -3
- data/distro/common/markdown/man1/knife-search.mkd +2 -2
- data/distro/common/markdown/man1/knife-ssh.mkd +1 -1
- data/distro/common/markdown/man1/knife-status.mkd +1 -1
- data/distro/common/markdown/man1/knife-tag.mkd +1 -1
- data/distro/common/markdown/man1/knife.mkd +2 -2
- data/distro/common/markdown/man8/chef-client.mkd +1 -2
- data/distro/common/markdown/man8/chef-expander.mkd +1 -2
- data/distro/common/markdown/man8/chef-expanderctl.mkd +1 -2
- data/distro/common/markdown/man8/chef-server-webui.mkd +1 -1
- data/distro/common/markdown/man8/chef-server.mkd +1 -2
- data/distro/common/markdown/man8/chef-solo.mkd +2 -2
- data/distro/common/markdown/man8/chef-solr.mkd +1 -1
- data/lib/chef/client.rb +2 -2
- data/lib/chef/config.rb +17 -709
- data/lib/chef/cookbook/metadata.rb +9 -5
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +2 -18
- data/lib/chef/dsl/definitions.rb +44 -0
- data/lib/chef/dsl/recipe.rb +50 -35
- data/lib/chef/dsl/resources.rb +28 -0
- data/lib/chef/event_dispatch/dispatcher.rb +2 -0
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -11
- data/lib/chef/exceptions.rb +4 -0
- data/lib/chef/file_access_control/unix.rb +5 -0
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +17 -0
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +21 -9
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +2 -0
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +2 -0
- data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +2 -0
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +4 -0
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +11 -1
- data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +2 -0
- data/lib/chef/http/authenticator.rb +3 -0
- data/lib/chef/http/basic_client.rb +10 -6
- data/lib/chef/http/json_input.rb +6 -1
- data/lib/chef/key.rb +271 -0
- data/lib/chef/knife.rb +11 -1
- data/lib/chef/knife/bootstrap.rb +6 -0
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +166 -23
- data/lib/chef/knife/client_key_create.rb +67 -0
- data/lib/chef/knife/client_key_delete.rb +76 -0
- data/lib/chef/knife/client_key_edit.rb +80 -0
- data/lib/chef/knife/client_key_list.rb +69 -0
- data/lib/chef/knife/client_key_show.rb +76 -0
- data/lib/chef/knife/key_create.rb +108 -0
- data/lib/chef/knife/key_create_base.rb +50 -0
- data/lib/chef/knife/key_delete.rb +55 -0
- data/lib/chef/knife/key_edit.rb +114 -0
- data/lib/chef/knife/key_edit_base.rb +55 -0
- data/lib/chef/knife/key_list.rb +88 -0
- data/lib/chef/knife/key_list_base.rb +45 -0
- data/lib/chef/knife/key_show.rb +53 -0
- data/lib/chef/knife/ssh.rb +26 -28
- data/lib/chef/knife/user_key_create.rb +69 -0
- data/lib/chef/knife/user_key_delete.rb +76 -0
- data/lib/chef/knife/user_key_edit.rb +80 -0
- data/lib/chef/knife/user_key_list.rb +69 -0
- data/lib/chef/knife/user_key_show.rb +76 -0
- data/lib/chef/log.rb +2 -0
- data/lib/chef/log/syslog.rb +46 -0
- data/lib/chef/log/winevt.rb +99 -0
- data/lib/chef/mixin/provides.rb +8 -1
- data/lib/chef/mixin/unformatter.rb +32 -0
- data/lib/chef/mixin/uris.rb +33 -0
- data/lib/chef/mixin/wstring.rb +31 -0
- data/lib/chef/node.rb +21 -2
- data/lib/chef/platform/provider_mapping.rb +8 -4
- data/lib/chef/platform/query_helpers.rb +1 -5
- data/lib/chef/platform/service_helpers.rb +21 -21
- data/lib/chef/provider.rb +33 -0
- data/lib/chef/provider/cron/unix.rb +1 -0
- data/lib/chef/provider/file.rb +5 -3
- data/lib/chef/provider/lwrp_base.rb +76 -58
- data/lib/chef/provider/ohai.rb +1 -0
- data/lib/chef/provider/package.rb +7 -4
- data/lib/chef/provider/package/aix.rb +1 -0
- data/lib/chef/provider/package/smartos.rb +5 -5
- data/lib/chef/provider/package/windows.rb +90 -6
- data/lib/chef/provider/package/yum.rb +102 -32
- data/lib/chef/provider/reboot.rb +1 -0
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file.rb +1 -0
- data/lib/chef/provider/remote_file/content.rb +5 -1
- data/lib/chef/provider/remote_file/fetcher.rb +22 -8
- data/lib/chef/provider/remote_file/network_file.rb +48 -0
- data/lib/chef/provider/service/aix.rb +13 -12
- data/lib/chef/provider_resolver.rb +87 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +67 -8
- data/lib/chef/resource/bash.rb +1 -0
- data/lib/chef/resource/bff_package.rb +1 -2
- data/lib/chef/resource/breakpoint.rb +1 -0
- data/lib/chef/resource/csh.rb +1 -0
- data/lib/chef/resource/deploy.rb +1 -0
- data/lib/chef/resource/erl_call.rb +1 -0
- data/lib/chef/resource/execute.rb +1 -0
- data/lib/chef/resource/file.rb +18 -0
- data/lib/chef/resource/http_request.rb +1 -0
- data/lib/chef/resource/ifconfig.rb +1 -2
- data/lib/chef/resource/log.rb +1 -2
- data/lib/chef/resource/lwrp_base.rb +106 -87
- data/lib/chef/resource/ohai.rb +1 -0
- data/lib/chef/resource/package.rb +1 -0
- data/lib/chef/resource/perl.rb +1 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/python.rb +1 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_file.rb +1 -1
- data/lib/chef/resource/route.rb +1 -2
- data/lib/chef/resource/ruby.rb +1 -0
- data/lib/chef/resource/ruby_block.rb +1 -0
- data/lib/chef/resource/scm.rb +1 -0
- data/lib/chef/resource/script.rb +1 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_package.rb +24 -2
- data/lib/chef/resource/windows_script.rb +1 -0
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_definition.rb +1 -0
- data/lib/chef/resource_reporter.rb +3 -10
- data/lib/chef/resource_resolver.rb +20 -10
- data/lib/chef/run_context.rb +1 -0
- data/lib/chef/run_list/versioned_recipe_list.rb +18 -0
- data/lib/chef/run_status.rb +2 -4
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/util/path_helper.rb +3 -204
- data/lib/chef/util/windows/net_user.rb +73 -118
- data/lib/chef/version.rb +8 -4
- data/lib/chef/win32/api.rb +2 -1
- data/lib/chef/win32/api/installer.rb +1 -1
- data/lib/chef/win32/api/net.rb +115 -2
- data/lib/chef/win32/api/security.rb +24 -0
- data/lib/chef/win32/api/unicode.rb +1 -1
- data/lib/chef/win32/eventlog.rb +31 -0
- data/lib/chef/win32/net.rb +190 -0
- data/lib/chef/win32/security.rb +51 -2
- data/lib/chef/win32/security/sid.rb +17 -0
- data/spec/data/lwrp/providers/buck_passer.rb +18 -2
- data/spec/data/lwrp/providers/buck_passer_2.rb +18 -2
- data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +14 -2
- data/spec/data/lwrp_override/resources/foo.rb +5 -0
- data/spec/functional/knife/ssh_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/aixinit_service_spec.rb +1 -1
- data/spec/functional/resource/user/windows_spec.rb +125 -0
- data/spec/functional/shell_spec.rb +25 -10
- data/spec/functional/win32/sid_spec.rb +55 -0
- data/spec/integration/client/client_spec.rb +53 -29
- data/spec/integration/knife/deps_spec.rb +8 -14
- data/spec/integration/knife/upload_spec.rb +18 -0
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/provider_choice.rb +41 -0
- data/spec/integration/recipes/recipe_dsl_spec.rb +259 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/key_helpers.rb +104 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +2 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +1 -0
- data/spec/support/lib/chef/resource/zen_master.rb +2 -0
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/pedant/Gemfile.lock +67 -0
- data/spec/support/shared/functional/securable_resource.rb +34 -12
- data/spec/support/shared/integration/integration_helper.rb +6 -5
- data/spec/support/shared/unit/provider/file.rb +31 -8
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/client_spec.rb +21 -4
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +15 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +1 -1
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_site_streaming_uploader_spec.rb +0 -21
- data/spec/unit/data_bag_spec.rb +1 -1
- data/spec/unit/event_dispatch/dispatcher_spec.rb +61 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +75 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +149 -112
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +7 -0
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +1 -1
- data/spec/unit/http/authenticator_spec.rb +69 -0
- data/spec/unit/http/basic_client_spec.rb +16 -0
- data/spec/unit/key_spec.rb +634 -0
- data/spec/unit/knife/bootstrap_spec.rb +14 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +1 -1
- data/spec/unit/knife/data_bag_from_file_spec.rb +1 -1
- data/spec/unit/knife/environment_from_file_spec.rb +1 -1
- data/spec/unit/knife/key_create_spec.rb +224 -0
- data/spec/unit/knife/key_delete_spec.rb +135 -0
- data/spec/unit/knife/key_edit_spec.rb +267 -0
- data/spec/unit/knife/key_helper.rb +74 -0
- data/spec/unit/knife/key_list_spec.rb +216 -0
- data/spec/unit/knife/key_show_spec.rb +126 -0
- data/spec/unit/knife/ssh_spec.rb +23 -26
- data/spec/unit/knife_spec.rb +33 -1
- data/spec/unit/log/syslog_spec.rb +53 -0
- data/spec/unit/log/winevt_spec.rb +55 -0
- data/spec/unit/lwrp_spec.rb +105 -51
- data/spec/unit/mixin/path_sanity_spec.rb +2 -2
- data/spec/unit/mixin/template_spec.rb +2 -2
- data/spec/unit/mixin/unformatter_spec.rb +61 -0
- data/spec/unit/mixin/uris_spec.rb +45 -0
- data/spec/unit/platform/query_helpers_spec.rb +1 -1
- data/spec/unit/policy_builder/policyfile_spec.rb +7 -3
- data/spec/unit/provider/deploy/revision_spec.rb +1 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +1 -1
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/package/aix_spec.rb +20 -8
- data/spec/unit/provider/package/smartos_spec.rb +50 -40
- data/spec/unit/provider/package/windows_spec.rb +104 -25
- data/spec/unit/provider/package/yum_spec.rb +111 -1
- data/spec/unit/provider/package_spec.rb +6 -0
- data/spec/unit/provider/remote_file/fetcher_spec.rb +20 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +45 -0
- data/spec/unit/provider/service/aix_service_spec.rb +26 -11
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_spec.rb +20 -0
- data/spec/unit/recipe_spec.rb +1 -1
- data/spec/unit/resource/batch_spec.rb +1 -0
- data/spec/unit/resource/powershell_spec.rb +1 -0
- data/spec/unit/resource/remote_file_spec.rb +10 -0
- data/spec/unit/resource/windows_package_spec.rb +16 -2
- data/spec/unit/resource_spec.rb +40 -24
- data/spec/unit/rest_spec.rb +10 -20
- data/spec/unit/role_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +31 -0
- data/spec/unit/shell_spec.rb +4 -4
- data/tasks/external_tests.rb +29 -0
- data/tasks/rspec.rb +14 -1
- metadata +105 -28
- data/spec/unit/config_spec.rb +0 -544
- data/spec/unit/util/path_helper_spec.rb +0 -255
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25c355c5fc851494511ffe3357dc70d4d33ce0a1
|
4
|
+
data.tar.gz: 58519eab83b8f84091f524d44885754f785bf5ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b7cf77faa3d392ad18934005d5127b4d157a71770f4b0e330e97f01cc288e4cd625f8491a1984a242854451f6d729f66269b95b5d40ab4ee674b812b1d33e1
|
7
|
+
data.tar.gz: 1e96c0418cdd9049c0a2dbfa0f5ac88da677cc978b42057abccfedc9c5dc5029c9cdf77b264207491fb33c1514f80496121d9df52012aefb66579ad1cfa691ac
|
data/Rakefile
CHANGED
@@ -17,31 +17,109 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
VERSION = IO.read(File.expand_path("../VERSION", __FILE__)).strip
|
21
21
|
|
22
22
|
require 'rubygems'
|
23
23
|
require 'rubygems/package_task'
|
24
24
|
require 'rdoc/task'
|
25
|
-
|
25
|
+
require_relative 'tasks/rspec'
|
26
|
+
require_relative 'tasks/external_tests'
|
26
27
|
|
27
28
|
GEM_NAME = "chef"
|
28
29
|
|
30
|
+
desc "build Gems of Chef's components"
|
31
|
+
task :package_components do
|
32
|
+
Dir.chdir("chef-config") do
|
33
|
+
sh "rake package"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task :package => :package_components
|
38
|
+
|
39
|
+
desc "build and install chef's components"
|
40
|
+
task :install_components => :package_components do
|
41
|
+
Dir.chdir("chef-config") do
|
42
|
+
sh "rake install"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
task :install => :install_components
|
47
|
+
|
48
|
+
desc "clean up builds of Chef's components"
|
49
|
+
task :clobber_component_packages do
|
50
|
+
Dir.chdir("chef-config") do
|
51
|
+
sh "rake clobber_package"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
task :clobber_package => :clobber_component_packages
|
56
|
+
|
57
|
+
desc "Update the version number for Chef's components"
|
58
|
+
task :update_components_versions do
|
59
|
+
Dir.chdir("chef-config") do
|
60
|
+
sh "rake version"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Regenerate lib/chef/version.rb from VERSION file"
|
65
|
+
task :version => :update_components_versions do
|
66
|
+
contents = <<-VERSION_RB
|
67
|
+
# Copyright:: Copyright (c) 2010-2015 Chef Software, Inc.
|
68
|
+
# License:: Apache License, Version 2.0
|
69
|
+
#
|
70
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
71
|
+
# you may not use this file except in compliance with the License.
|
72
|
+
# You may obtain a copy of the License at
|
73
|
+
#
|
74
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
75
|
+
#
|
76
|
+
# Unless required by applicable law or agreed to in writing, software
|
77
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
78
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
79
|
+
# See the License for the specific language governing permissions and
|
80
|
+
# limitations under the License.
|
81
|
+
|
82
|
+
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
83
|
+
# NOTE: This file is generated by running `rake version` in the top level of
|
84
|
+
# this repo. Do not edit this manually. Edit the VERSION file and run the rake
|
85
|
+
# task instead.
|
86
|
+
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
87
|
+
|
88
|
+
class Chef
|
89
|
+
CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
90
|
+
VERSION = '#{VERSION}'
|
91
|
+
end
|
92
|
+
|
93
|
+
#
|
94
|
+
# NOTE: the Chef::Version class is defined in version_class.rb
|
95
|
+
#
|
96
|
+
# NOTE: DO NOT Use the Chef::Version class on Chef::VERSIONs. The
|
97
|
+
# Chef::Version class is for _cookbooks_ only, and cannot handle
|
98
|
+
# pre-release chef-client versions like "10.14.0.rc.2". Please
|
99
|
+
# use Rubygem's Gem::Version class instead.
|
100
|
+
#
|
101
|
+
VERSION_RB
|
102
|
+
version_rb_path = File.expand_path("../lib/chef/version.rb", __FILE__)
|
103
|
+
IO.write(version_rb_path, contents)
|
104
|
+
end
|
105
|
+
|
29
106
|
Dir[File.expand_path("../*gemspec", __FILE__)].reverse.each do |gemspec_path|
|
30
107
|
gemspec = eval(IO.read(gemspec_path))
|
31
108
|
Gem::PackageTask.new(gemspec).define
|
32
109
|
end
|
33
110
|
|
34
|
-
|
35
|
-
|
111
|
+
desc "Build and install a chef gem"
|
112
|
+
task :install => [:package] do
|
113
|
+
sh %{gem install pkg/#{GEM_NAME}-#{VERSION}.gem --no-rdoc --no-ri}
|
36
114
|
end
|
37
115
|
|
38
116
|
task :uninstall do
|
39
|
-
sh %{gem uninstall #{GEM_NAME} -x -v #{
|
117
|
+
sh %{gem uninstall #{GEM_NAME} -x -v #{VERSION} }
|
40
118
|
end
|
41
119
|
|
42
120
|
desc "Build it, tag it and ship it"
|
43
|
-
task :ship => :gem do
|
44
|
-
sh("git tag #{
|
121
|
+
task :ship => [:clobber_package, :gem] do
|
122
|
+
sh("git tag #{VERSION}")
|
45
123
|
sh("git push opscode --tags")
|
46
124
|
Dir[File.expand_path("../pkg/*.gem", __FILE__)].reverse.each do |built_gem|
|
47
125
|
sh("gem push #{built_gem}")
|
@@ -79,3 +157,4 @@ begin
|
|
79
157
|
rescue LoadError
|
80
158
|
puts "yard is not available. (sudo) gem install yard to generate yard documentation."
|
81
159
|
end
|
160
|
+
|
@@ -131,8 +131,8 @@ Recipe mode implements Chef's recipe DSL. Exhaustively documenting this
|
|
131
131
|
DSL is outside the scope of this document. See the following pages in
|
132
132
|
the Chef documentation for more information:
|
133
133
|
|
134
|
-
* <http://
|
135
|
-
* <http://
|
134
|
+
* <http://docs.chef.io/resources.html>
|
135
|
+
* <http://docs.chef.io/recipes.html>
|
136
136
|
|
137
137
|
Once you have defined resources in the recipe, you can trigger a
|
138
138
|
convergence run via `run_chef`
|
@@ -176,7 +176,7 @@ libraries.
|
|
176
176
|
## SEE ALSO
|
177
177
|
|
178
178
|
chef-client(8) knife(1)
|
179
|
-
<http://
|
179
|
+
<http://docs.chef.io/ctl_chef_shell.html>
|
180
180
|
|
181
181
|
## AUTHOR
|
182
182
|
|
@@ -192,4 +192,4 @@ libraries.
|
|
192
192
|
|
193
193
|
## CHEF
|
194
194
|
|
195
|
-
chef-shell is distributed with Chef. <http://
|
195
|
+
chef-shell is distributed with Chef. <http://docs.chef.io>
|
@@ -99,5 +99,5 @@ setting up a host for management with Chef.
|
|
99
99
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
100
100
|
|
101
101
|
## CHEF
|
102
|
-
Knife is distributed with Chef. <http://
|
102
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
103
103
|
|
@@ -66,5 +66,5 @@ the specified _directory_.
|
|
66
66
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
67
67
|
|
68
68
|
## CHEF
|
69
|
-
Knife is distributed with Chef. <http://
|
69
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
70
70
|
|
@@ -119,5 +119,5 @@ Uploading cookbooks to the Opscode cookbooks site:
|
|
119
119
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
120
120
|
|
121
121
|
## CHEF
|
122
|
-
Knife is distributed with Chef. <http://
|
122
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
123
123
|
|
@@ -236,7 +236,7 @@ to specify alternate files to be used on a specific OS platform or host.
|
|
236
236
|
The default specificity setting is _default_, that is files in
|
237
237
|
`COOKBOOK/files/default` will be used when a more specific copy is not
|
238
238
|
available. Further documentation for this feature is available on the
|
239
|
-
Chef wiki: <
|
239
|
+
Chef wiki: <https://docs.chef.io/resource_cookbook_file.html#file-specificity>
|
240
240
|
|
241
241
|
Cookbooks also contain a metadata file that defines various properties
|
242
242
|
of the cookbook. The most important of these are the _version_ and the
|
@@ -248,8 +248,8 @@ cookbook.
|
|
248
248
|
|
249
249
|
## SEE ALSO
|
250
250
|
__knife-environment(1)__ __knife-cookbook-site(1)__
|
251
|
-
<http://
|
252
|
-
<http://
|
251
|
+
<http://docs.chef.io/cookbooks.html>
|
252
|
+
<http://docs.chef.io/cookbook_repo.html>
|
253
253
|
|
254
254
|
## AUTHOR
|
255
255
|
Chef was written by Adam Jacob <adam@opscode.com> with many contributions from the community.
|
@@ -260,4 +260,4 @@ cookbook.
|
|
260
260
|
|
261
261
|
|
262
262
|
## CHEF
|
263
|
-
Knife is distributed with Chef. <http://
|
263
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
@@ -117,5 +117,5 @@ encryption keys.
|
|
117
117
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
118
118
|
|
119
119
|
## CHEF
|
120
|
-
Knife is distributed with Chef. http://
|
120
|
+
Knife is distributed with Chef. http://docs.chef.io/
|
121
121
|
|
@@ -137,8 +137,8 @@ The Ruby format of an environment is as follows:
|
|
137
137
|
|
138
138
|
## SEE ALSO
|
139
139
|
__knife-node(1)__ __knife-cookbook(1)__ __knife-role(1)__
|
140
|
-
<http://
|
141
|
-
<http://
|
140
|
+
<http://docs.chef.io/environments.html>
|
141
|
+
<http://docs.chef.io/cookbook_versions.html>
|
142
142
|
|
143
143
|
## AUTHOR
|
144
144
|
Chef was written by Adam Jacob <adam@opscode.com> with many contributions from the community.
|
@@ -148,4 +148,4 @@ The Ruby format of an environment is as follows:
|
|
148
148
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
149
149
|
|
150
150
|
## CHEF
|
151
|
-
Knife is distributed with Chef. <http://
|
151
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
@@ -26,5 +26,5 @@ time for all objects to be indexed and available for search.
|
|
26
26
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
27
27
|
|
28
28
|
## CHEF
|
29
|
-
Knife is distributed with Chef. <http://
|
29
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
30
30
|
|
@@ -126,5 +126,5 @@ When adding a recipe to a run list, there are several valid formats:
|
|
126
126
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
127
127
|
|
128
128
|
## CHEF
|
129
|
-
Knife is distributed with Chef. <http://
|
129
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
130
130
|
|
@@ -70,8 +70,8 @@ run\_list.
|
|
70
70
|
|
71
71
|
## SEE ALSO
|
72
72
|
__knife-node(1)__ __knife-environment(1)__
|
73
|
-
<http://
|
74
|
-
<http://
|
73
|
+
<http://docs.chef.io/roles.html>
|
74
|
+
<http://docs.chef.io/attributes.html>
|
75
75
|
|
76
76
|
## AUTHOR
|
77
77
|
Chef was written by Adam Jacob <adam@opscode.com> with many contributions from the community.
|
@@ -81,5 +81,5 @@ run\_list.
|
|
81
81
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
82
82
|
|
83
83
|
## CHEF
|
84
|
-
Knife is distributed with Chef. <http://
|
84
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
85
85
|
|
@@ -164,7 +164,7 @@ Find all nodes running CentOS in the production environment:
|
|
164
164
|
|
165
165
|
## SEE ALSO
|
166
166
|
__knife-ssh__(1)
|
167
|
-
<http://
|
167
|
+
<http://docs.chef.io/attributes.html>
|
168
168
|
[Lucene Query Parser Syntax](http://lucene.apache.org/java/2_3_2/queryparsersyntax.html)
|
169
169
|
|
170
170
|
## AUTHOR
|
@@ -175,6 +175,6 @@ Find all nodes running CentOS in the production environment:
|
|
175
175
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
176
176
|
|
177
177
|
## CHEF
|
178
|
-
Knife is distributed with Chef. <http://
|
178
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
179
179
|
|
180
180
|
|
@@ -64,6 +64,6 @@ The available multiplexers are:
|
|
64
64
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
65
65
|
|
66
66
|
## CHEF
|
67
|
-
Knife is distributed with Chef. <http://
|
67
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
68
68
|
|
69
69
|
|
@@ -31,6 +31,6 @@ may not be publicly reachable.
|
|
31
31
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
32
32
|
|
33
33
|
## CHEF
|
34
|
-
Knife is distributed with Chef. <http://
|
34
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
35
35
|
|
36
36
|
|
@@ -35,5 +35,5 @@ Lists the tags applied to _node_
|
|
35
35
|
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
|
36
36
|
|
37
37
|
## CHEF
|
38
|
-
Knife is distributed with Chef. <http://
|
38
|
+
Knife is distributed with Chef. <http://docs.chef.io>
|
39
39
|
|
@@ -186,7 +186,7 @@ recommended though, and git fits with a lot of the workflow paradigms.
|
|
186
186
|
__knife-node(1)__ __knife-recipe(1)__ __knife-role(1)__
|
187
187
|
__knife-search(1)__ __knife-ssh(1)__ __knife-tag(1)__
|
188
188
|
|
189
|
-
Complete Chef documentation is available online: <http://
|
189
|
+
Complete Chef documentation is available online: <http://docs.chef.io/>
|
190
190
|
|
191
191
|
JSON is JavaScript Object Notation <http://json.org/>
|
192
192
|
|
@@ -209,5 +209,5 @@ recommended though, and git fits with a lot of the workflow paradigms.
|
|
209
209
|
On some systems, the complete text of the Apache 2.0 License may be found in `/usr/share/common-licenses/Apache-2.0`.
|
210
210
|
|
211
211
|
## CHEF
|
212
|
-
Knife is distributed with Chef. <http://
|
212
|
+
Knife is distributed with Chef. <http://docs.chef.io/>
|
213
213
|
|
@@ -59,8 +59,7 @@ are largely services that exist only to provide the Client with information.
|
|
59
59
|
|
60
60
|
## SEE ALSO
|
61
61
|
|
62
|
-
Full documentation for Chef and chef-client is located on
|
63
|
-
wiki, http://wiki.opscode.com/display/chef/Home.
|
62
|
+
Full documentation for Chef and chef-client is located on docs site, http://docs.chef.io/.
|
64
63
|
|
65
64
|
## AUTHOR
|
66
65
|
|
@@ -67,8 +67,7 @@ See __chef-expanderctl__(8) for details.
|
|
67
67
|
__chef-expanderctl__(8)
|
68
68
|
__chef-solr__(8)
|
69
69
|
|
70
|
-
Full documentation for Chef and chef-server is located on
|
71
|
-
wiki, http://wiki.opscode.com/display/chef/Home.
|
70
|
+
Full documentation for Chef and chef-server is located on docs site, http://docs.chef.io/.
|
72
71
|
|
73
72
|
## AUTHOR
|
74
73
|
|
@@ -43,8 +43,7 @@ be restarted by the master process.
|
|
43
43
|
__chef-expander-cluster__(8)
|
44
44
|
__chef-solr__(8)
|
45
45
|
|
46
|
-
Full documentation for Chef and chef-server is located on
|
47
|
-
wiki, http://wiki.opscode.com/display/chef/Home.
|
46
|
+
Full documentation for Chef and chef-server is located on docs site, http://docs.chef.io/.
|
48
47
|
|
49
48
|
## AUTHOR
|
50
49
|
|
@@ -106,7 +106,7 @@ The default credentials are:
|
|
106
106
|
## SEE ALSO
|
107
107
|
|
108
108
|
Full documentation for Chef and chef-server-webui (Management Console)
|
109
|
-
is located on the Chef
|
109
|
+
is located on the Chef docs site, http://docs.chef.io/.
|
110
110
|
|
111
111
|
## AUTHOR
|
112
112
|
|
@@ -106,8 +106,7 @@ __chef-client__(8)
|
|
106
106
|
__chef-server-webui__(8)
|
107
107
|
__knife__(1)
|
108
108
|
|
109
|
-
Full documentation for Chef and chef-server is located on
|
110
|
-
wiki, http://wiki.opscode.com/display/chef/Home.
|
109
|
+
Full documentation for Chef and chef-server is located on docs site, http://docs.chef.io/.
|
111
110
|
|
112
111
|
## AUTHOR
|
113
112
|
|
@@ -92,8 +92,8 @@ and use the run_list from ~/node.json.
|
|
92
92
|
|
93
93
|
## SEE ALSO
|
94
94
|
|
95
|
-
Full documentation for Chef and chef-solo is located on the Chef
|
96
|
-
http://
|
95
|
+
Full documentation for Chef and chef-solo is located on the Chef docs site,
|
96
|
+
http://docs.chef.io/.
|
97
97
|
|
98
98
|
## AUTHOR
|
99
99
|
|
@@ -75,7 +75,7 @@ when prompted for confirmation. The process should look like this:
|
|
75
75
|
__chef-expander-cluster__(8)
|
76
76
|
|
77
77
|
Full documentation for Chef and chef-server is located on the Chef
|
78
|
-
|
78
|
+
Docs site, http://docs.chef.io/.
|
79
79
|
|
80
80
|
## AUTHOR
|
81
81
|
|
data/lib/chef/client.rb
CHANGED
@@ -152,7 +152,6 @@ class Chef
|
|
152
152
|
def initialize(json_attribs=nil, args={})
|
153
153
|
@json_attribs = json_attribs || {}
|
154
154
|
@node = nil
|
155
|
-
@run_status = nil
|
156
155
|
@runner = nil
|
157
156
|
@ohai = Ohai::System.new
|
158
157
|
|
@@ -162,6 +161,7 @@ class Chef
|
|
162
161
|
@events = EventDispatch::Dispatcher.new(*event_handlers)
|
163
162
|
@override_runlist = args.delete(:override_runlist)
|
164
163
|
@specific_recipes = args.delete(:specific_recipes)
|
164
|
+
@run_status = Chef::RunStatus.new(node, events)
|
165
165
|
|
166
166
|
if new_runlist = args.delete(:runlist)
|
167
167
|
@json_attribs["run_list"] = new_runlist
|
@@ -248,7 +248,7 @@ class Chef
|
|
248
248
|
# @return [Chef::Node] The updated node object
|
249
249
|
def build_node
|
250
250
|
policy_builder.build_node
|
251
|
-
@run_status =
|
251
|
+
@run_status.node = node
|
252
252
|
node
|
253
253
|
end
|
254
254
|
|
data/lib/chef/config.rb
CHANGED
@@ -20,727 +20,35 @@
|
|
20
20
|
# limitations under the License.
|
21
21
|
|
22
22
|
require 'chef/log'
|
23
|
-
require 'chef/
|
24
|
-
require 'mixlib/config'
|
25
|
-
require 'chef/util/selinux'
|
26
|
-
require 'chef/util/path_helper'
|
27
|
-
require 'pathname'
|
28
|
-
require 'chef/mixin/shell_out'
|
23
|
+
require 'chef-config/logger'
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
extend Chef::Mixin::ShellOut
|
35
|
-
|
36
|
-
PathHelper = Chef::Util::PathHelper
|
37
|
-
|
38
|
-
# Evaluates the given string as config.
|
39
|
-
#
|
40
|
-
# +filename+ is used for context in stacktraces, but doesn't need to be the name of an actual file.
|
41
|
-
def self.from_string(string, filename)
|
42
|
-
self.instance_eval(string, filename, 1)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Manages the chef secret session key
|
46
|
-
# === Returns
|
47
|
-
# <newkey>:: A new or retrieved session key
|
48
|
-
#
|
49
|
-
def self.manage_secret_key
|
50
|
-
newkey = nil
|
51
|
-
if Chef::FileCache.has_key?("chef_server_cookie_id")
|
52
|
-
newkey = Chef::FileCache.load("chef_server_cookie_id")
|
53
|
-
else
|
54
|
-
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
55
|
-
newkey = ""
|
56
|
-
40.times { |i| newkey << chars[rand(chars.size-1)] }
|
57
|
-
Chef::FileCache.store("chef_server_cookie_id", newkey)
|
58
|
-
end
|
59
|
-
newkey
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.inspect
|
63
|
-
configuration.inspect
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.platform_specific_path(path)
|
67
|
-
path = PathHelper.cleanpath(path)
|
68
|
-
if Chef::Platform.windows?
|
69
|
-
# turns \etc\chef\client.rb and \var\chef\client.rb into C:/chef/client.rb
|
70
|
-
if env['SYSTEMDRIVE'] && path[0] == '\\' && path.split('\\')[2] == 'chef'
|
71
|
-
path = PathHelper.join(env['SYSTEMDRIVE'], path.split('\\', 3)[2])
|
72
|
-
end
|
73
|
-
end
|
74
|
-
path
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.add_formatter(name, file_path=nil)
|
78
|
-
formatters << [name, file_path]
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.add_event_logger(logger)
|
82
|
-
event_handlers << logger
|
83
|
-
end
|
84
|
-
|
85
|
-
# Config file to load (client.rb, knife.rb, etc. defaults set differently in knife, chef-client, etc.)
|
86
|
-
configurable(:config_file)
|
87
|
-
|
88
|
-
default(:config_dir) do
|
89
|
-
if config_file
|
90
|
-
PathHelper.dirname(config_file)
|
91
|
-
else
|
92
|
-
PathHelper.join(user_home, ".chef", "")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
default :formatters, []
|
97
|
-
|
98
|
-
# Override the config dispatch to set the value of multiple server options simultaneously
|
99
|
-
#
|
100
|
-
# === Parameters
|
101
|
-
# url<String>:: String to be set for all of the chef-server-api URL's
|
102
|
-
#
|
103
|
-
configurable(:chef_server_url).writes_value { |url| url.to_s.strip }
|
104
|
-
|
105
|
-
# When you are using ActiveSupport, they monkey-patch 'daemonize' into Kernel.
|
106
|
-
# So while this is basically identical to what method_missing would do, we pull
|
107
|
-
# it up here and get a real method written so that things get dispatched
|
108
|
-
# properly.
|
109
|
-
configurable(:daemonize).writes_value { |v| v }
|
110
|
-
|
111
|
-
# The root where all local chef object data is stored. cookbooks, data bags,
|
112
|
-
# environments are all assumed to be in separate directories under this.
|
113
|
-
# chef-solo uses these directories for input data. knife commands
|
114
|
-
# that upload or download files (such as knife upload, knife role from file,
|
115
|
-
# etc.) work.
|
116
|
-
default :chef_repo_path do
|
117
|
-
if self.configuration[:cookbook_path]
|
118
|
-
if self.configuration[:cookbook_path].kind_of?(String)
|
119
|
-
File.expand_path('..', self.configuration[:cookbook_path])
|
120
|
-
else
|
121
|
-
self.configuration[:cookbook_path].map do |path|
|
122
|
-
File.expand_path('..', path)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
else
|
126
|
-
cache_path
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
def self.find_chef_repo_path(cwd)
|
131
|
-
# In local mode, we auto-discover the repo root by looking for a path with "cookbooks" under it.
|
132
|
-
# This allows us to run config-free.
|
133
|
-
path = cwd
|
134
|
-
until File.directory?(PathHelper.join(path, "cookbooks"))
|
135
|
-
new_path = File.expand_path('..', path)
|
136
|
-
if new_path == path
|
137
|
-
Chef::Log.warn("No cookbooks directory found at or above current directory. Assuming #{Dir.pwd}.")
|
138
|
-
return Dir.pwd
|
139
|
-
end
|
140
|
-
path = new_path
|
141
|
-
end
|
142
|
-
Chef::Log.info("Auto-discovered chef repository at #{path}")
|
143
|
-
path
|
144
|
-
end
|
145
|
-
|
146
|
-
def self.derive_path_from_chef_repo_path(child_path)
|
147
|
-
if chef_repo_path.kind_of?(String)
|
148
|
-
PathHelper.join(chef_repo_path, child_path)
|
149
|
-
else
|
150
|
-
chef_repo_path.map { |path| PathHelper.join(path, child_path)}
|
151
|
-
end
|
152
|
-
end
|
25
|
+
# DI our logger into ChefConfig before we load the config. Some defaults are
|
26
|
+
# auto-detected, and this emits log messages on some systems, all of which will
|
27
|
+
# occur at require-time. So we need to set the logger first.
|
28
|
+
ChefConfig.logger = Chef::Log
|
153
29
|
|
154
|
-
|
155
|
-
# Defaults to <chef_repo_path>/acls.
|
156
|
-
# Only applies to Enterprise Chef commands.
|
157
|
-
default(:acl_path) { derive_path_from_chef_repo_path('acls') }
|
30
|
+
require 'chef-config/config'
|
158
31
|
|
159
|
-
|
160
|
-
# Defaults to <chef_repo_path>/acls.
|
161
|
-
default(:client_path) { derive_path_from_chef_repo_path('clients') }
|
162
|
-
|
163
|
-
# Location of cookbooks on disk. String or array of strings.
|
164
|
-
# Defaults to <chef_repo_path>/cookbooks. If chef_repo_path
|
165
|
-
# is not specified, this is set to [/var/chef/cookbooks, /var/chef/site-cookbooks]).
|
166
|
-
default(:cookbook_path) do
|
167
|
-
if self.configuration[:chef_repo_path]
|
168
|
-
derive_path_from_chef_repo_path('cookbooks')
|
169
|
-
else
|
170
|
-
Array(derive_path_from_chef_repo_path('cookbooks')).flatten +
|
171
|
-
Array(derive_path_from_chef_repo_path('site-cookbooks')).flatten
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
# Location of containers on disk. String or array of strings.
|
176
|
-
# Defaults to <chef_repo_path>/containers.
|
177
|
-
# Only applies to Enterprise Chef commands.
|
178
|
-
default(:container_path) { derive_path_from_chef_repo_path('containers') }
|
179
|
-
|
180
|
-
# Location of data bags on disk. String or array of strings.
|
181
|
-
# Defaults to <chef_repo_path>/data_bags.
|
182
|
-
default(:data_bag_path) { derive_path_from_chef_repo_path('data_bags') }
|
183
|
-
|
184
|
-
# Location of environments on disk. String or array of strings.
|
185
|
-
# Defaults to <chef_repo_path>/environments.
|
186
|
-
default(:environment_path) { derive_path_from_chef_repo_path('environments') }
|
187
|
-
|
188
|
-
# Location of groups on disk. String or array of strings.
|
189
|
-
# Defaults to <chef_repo_path>/groups.
|
190
|
-
# Only applies to Enterprise Chef commands.
|
191
|
-
default(:group_path) { derive_path_from_chef_repo_path('groups') }
|
192
|
-
|
193
|
-
# Location of nodes on disk. String or array of strings.
|
194
|
-
# Defaults to <chef_repo_path>/nodes.
|
195
|
-
default(:node_path) { derive_path_from_chef_repo_path('nodes') }
|
196
|
-
|
197
|
-
# Location of roles on disk. String or array of strings.
|
198
|
-
# Defaults to <chef_repo_path>/roles.
|
199
|
-
default(:role_path) { derive_path_from_chef_repo_path('roles') }
|
200
|
-
|
201
|
-
# Location of users on disk. String or array of strings.
|
202
|
-
# Defaults to <chef_repo_path>/users.
|
203
|
-
# Does not apply to Enterprise Chef commands.
|
204
|
-
default(:user_path) { derive_path_from_chef_repo_path('users') }
|
205
|
-
|
206
|
-
# Location of policies on disk. String or array of strings.
|
207
|
-
# Defaults to <chef_repo_path>/policies.
|
208
|
-
default(:policy_path) { derive_path_from_chef_repo_path('policies') }
|
209
|
-
|
210
|
-
# Turn on "path sanity" by default. See also: http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity
|
211
|
-
default :enforce_path_sanity, true
|
212
|
-
|
213
|
-
# Formatted Chef Client output is a beta feature, disabled by default:
|
214
|
-
default :formatter, "null"
|
215
|
-
|
216
|
-
# The number of times the client should retry when registering with the server
|
217
|
-
default :client_registration_retries, 5
|
218
|
-
|
219
|
-
# An array of paths to search for knife exec scripts if they aren't in the current directory
|
220
|
-
default :script_path, []
|
221
|
-
|
222
|
-
# The root of all caches (checksums, cache and backup). If local mode is on,
|
223
|
-
# this is under the user's home directory.
|
224
|
-
default(:cache_path) do
|
225
|
-
if local_mode
|
226
|
-
PathHelper.join(config_dir, 'local-mode-cache')
|
227
|
-
else
|
228
|
-
primary_cache_root = platform_specific_path("/var")
|
229
|
-
primary_cache_path = platform_specific_path("/var/chef")
|
230
|
-
# Use /var/chef as the cache path only if that folder exists and we can read and write
|
231
|
-
# into it, or /var exists and we can read and write into it (we'll create /var/chef later).
|
232
|
-
# Otherwise, we'll create .chef under the user's home directory and use that as
|
233
|
-
# the cache path.
|
234
|
-
unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root)
|
235
|
-
secondary_cache_path = PathHelper.join(user_home, '.chef')
|
236
|
-
Chef::Log.info("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
|
237
|
-
secondary_cache_path
|
238
|
-
else
|
239
|
-
primary_cache_path
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
# Returns true only if the path exists and is readable and writeable for the user.
|
245
|
-
def self.path_accessible?(path)
|
246
|
-
File.exists?(path) && File.readable?(path) && File.writable?(path)
|
247
|
-
end
|
248
|
-
|
249
|
-
# Where cookbook files are stored on the server (by content checksum)
|
250
|
-
default(:checksum_path) { PathHelper.join(cache_path, "checksums") }
|
251
|
-
|
252
|
-
# Where chef's cache files should be stored
|
253
|
-
default(:file_cache_path) { PathHelper.join(cache_path, "cache") }
|
254
|
-
|
255
|
-
# Where backups of chef-managed files should go
|
256
|
-
default(:file_backup_path) { PathHelper.join(cache_path, "backup") }
|
257
|
-
|
258
|
-
# The chef-client (or solo) lockfile.
|
259
|
-
#
|
260
|
-
# If your `file_cache_path` resides on a NFS (or non-flock()-supporting
|
261
|
-
# fs), it's recommended to set this to something like
|
262
|
-
# '/tmp/chef-client-running.pid'
|
263
|
-
default(:lockfile) { PathHelper.join(file_cache_path, "chef-client-running.pid") }
|
264
|
-
|
265
|
-
## Daemonization Settings ##
|
266
|
-
# What user should Chef run as?
|
267
|
-
default :user, nil
|
268
|
-
default :group, nil
|
269
|
-
default :umask, 0022
|
270
|
-
|
271
|
-
# Valid log_levels are:
|
272
|
-
# * :debug
|
273
|
-
# * :info
|
274
|
-
# * :warn
|
275
|
-
# * :fatal
|
276
|
-
# These work as you'd expect. There is also a special `:auto` setting.
|
277
|
-
# When set to :auto, Chef will auto adjust the log verbosity based on
|
278
|
-
# context. When a tty is available (usually because the user is running chef
|
279
|
-
# in a console), the log level is set to :warn, and output formatters are
|
280
|
-
# used as the primary mode of output. When a tty is not available, the
|
281
|
-
# logger is the primary mode of output, and the log level is set to :info
|
282
|
-
default :log_level, :auto
|
283
|
-
|
284
|
-
# Logging location as either an IO stream or string representing log file path
|
285
|
-
default :log_location, STDOUT
|
286
|
-
|
287
|
-
# Using `force_formatter` causes chef to default to formatter output when STDOUT is not a tty
|
288
|
-
default :force_formatter, false
|
289
|
-
|
290
|
-
# Using `force_logger` causes chef to default to logger output when STDOUT is a tty
|
291
|
-
default :force_logger, false
|
292
|
-
|
293
|
-
default :http_retry_count, 5
|
294
|
-
default :http_retry_delay, 5
|
295
|
-
default :interval, nil
|
296
|
-
default :once, nil
|
297
|
-
default :json_attribs, nil
|
298
|
-
# toggle info level log items that can create a lot of output
|
299
|
-
default :verbose_logging, true
|
300
|
-
default :node_name, nil
|
301
|
-
default :diff_disabled, false
|
302
|
-
default :diff_filesize_threshold, 10000000
|
303
|
-
default :diff_output_threshold, 1000000
|
304
|
-
default :local_mode, false
|
305
|
-
|
306
|
-
default :pid_file, nil
|
307
|
-
|
308
|
-
# Whether Chef Zero local mode should bind to a port. All internal requests
|
309
|
-
# will go through the socketless code path regardless, so the socket is
|
310
|
-
# only needed if other processes will connect to the local mode server.
|
311
|
-
#
|
312
|
-
# For compatibility this is set to true but it will be changed to false in
|
313
|
-
# the future.
|
314
|
-
default :listen, true
|
315
|
-
|
316
|
-
config_context :chef_zero do
|
317
|
-
config_strict_mode true
|
318
|
-
default(:enabled) { Chef::Config.local_mode }
|
319
|
-
default :host, 'localhost'
|
320
|
-
default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works
|
321
|
-
end
|
322
|
-
default :chef_server_url, "https://localhost:443"
|
32
|
+
require 'chef/platform/query_helpers'
|
323
33
|
|
324
|
-
|
325
|
-
|
326
|
-
default :yum_lock_timeout, 30
|
327
|
-
default :solo, false
|
328
|
-
default :splay, nil
|
329
|
-
default :why_run, false
|
330
|
-
default :color, false
|
331
|
-
default :client_fork, true
|
332
|
-
default :ez, false
|
333
|
-
default :enable_reporting, true
|
334
|
-
default :enable_reporting_url_fatals, false
|
335
|
-
# Possible values for :audit_mode
|
336
|
-
# :enabled, :disabled, :audit_only,
|
337
|
-
#
|
338
|
-
# TODO: 11 Dec 2014: Currently audit-mode is an experimental feature
|
339
|
-
# and is disabled by default. When users choose to enable audit-mode,
|
340
|
-
# a warning is issued in application/client#reconfigure.
|
341
|
-
# This can be removed when audit-mode is enabled by default.
|
342
|
-
default :audit_mode, :disabled
|
343
|
-
|
344
|
-
# Chef only needs ohai to run the hostname plugin for the most basic
|
345
|
-
# functionality. If the rest of the ohai plugins are not needed (like in
|
346
|
-
# most of our testing scenarios)
|
347
|
-
default :minimal_ohai, false
|
348
|
-
|
349
|
-
# Policyfile is an experimental feature where a node gets its run list and
|
350
|
-
# cookbook version set from a single document on the server instead of
|
351
|
-
# expanding the run list and having the server compute the cookbook version
|
352
|
-
# set based on environment constraints.
|
353
|
-
#
|
354
|
-
# Because this feature is experimental, it is not recommended for
|
355
|
-
# production use. Developent/release of this feature may not adhere to
|
356
|
-
# semver guidelines.
|
357
|
-
default :use_policyfile, false
|
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) { Chef::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 Chef::Platform.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, []
|
34
|
+
class Chef
|
35
|
+
Config = ChefConfig::Config
|
486
36
|
|
487
|
-
|
488
|
-
|
37
|
+
# We re-open ChefConfig::Config to add additional settings. Generally,
|
38
|
+
# everything should go in chef-config so it's shared with whoever uses that.
|
39
|
+
# We make execeptions to that rule when:
|
40
|
+
# * The functionality isn't likely to be useful outside of Chef
|
41
|
+
# * The functionality makes use of a dependency we don't want to add to chef-config
|
42
|
+
class Config
|
489
43
|
|
490
|
-
default :disable_event_loggers, false
|
491
44
|
default :event_loggers do
|
492
45
|
evt_loggers = []
|
493
|
-
if
|
46
|
+
if ChefConfig.windows? and not Chef::Platform.windows_server_2003?
|
494
47
|
evt_loggers << :win_evt
|
495
48
|
end
|
496
49
|
evt_loggers
|
497
50
|
end
|
498
51
|
|
499
|
-
# Exception Handlers
|
500
|
-
default :exception_handlers, []
|
501
|
-
|
502
|
-
# Start handlers
|
503
|
-
default :start_handlers, []
|
504
|
-
|
505
|
-
# Syntax Check Cache. Knife keeps track of files that is has already syntax
|
506
|
-
# checked by storing files in this directory. `syntax_check_cache_path` is
|
507
|
-
# the new (and preferred) configuration setting. If not set, knife will
|
508
|
-
# fall back to using cache_options[:path], which is deprecated but exists in
|
509
|
-
# many client configs generated by pre-Chef-11 bootstrappers.
|
510
|
-
default(:syntax_check_cache_path) { cache_options[:path] }
|
511
|
-
|
512
|
-
# Deprecated:
|
513
|
-
# Move this to the default value of syntax_cache_path when this is removed.
|
514
|
-
default(:cache_options) { { :path => PathHelper.join(config_dir, "syntaxcache") } }
|
515
|
-
|
516
|
-
# Whether errors should be raised for deprecation warnings. When set to
|
517
|
-
# `false` (the default setting), a warning is emitted but code using
|
518
|
-
# deprecated methods/features/etc. should work normally otherwise. When set
|
519
|
-
# to `true`, usage of deprecated methods/features will raise a
|
520
|
-
# `DeprecatedFeatureError`. This is used by Chef's tests to ensure that
|
521
|
-
# deprecated functionality is not used internally by Chef. End users
|
522
|
-
# should generally leave this at the default setting (especially in
|
523
|
-
# production), but it may be useful when testing cookbooks or other code if
|
524
|
-
# the user wishes to aggressively address deprecations.
|
525
|
-
default(:treat_deprecation_warnings_as_errors) do
|
526
|
-
# Using an environment variable allows this setting to be inherited in
|
527
|
-
# tests that spawn new processes.
|
528
|
-
ENV.key?("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS")
|
529
|
-
end
|
530
|
-
|
531
|
-
# knife configuration data
|
532
|
-
config_context :knife do
|
533
|
-
default :ssh_port, nil
|
534
|
-
default :ssh_user, nil
|
535
|
-
default :ssh_attribute, nil
|
536
|
-
default :ssh_gateway, nil
|
537
|
-
default :bootstrap_version, nil
|
538
|
-
default :bootstrap_proxy, nil
|
539
|
-
default :bootstrap_template, nil
|
540
|
-
default :secret, nil
|
541
|
-
default :secret_file, nil
|
542
|
-
default :identity_file, nil
|
543
|
-
default :host_key_verify, nil
|
544
|
-
default :forward_agent, nil
|
545
|
-
default :sort_status_reverse, nil
|
546
|
-
default :hints, {}
|
547
|
-
end
|
548
|
-
|
549
|
-
def self.set_defaults_for_windows
|
550
|
-
# Those lists of regular expressions define what chef considers a
|
551
|
-
# valid user and group name
|
552
|
-
# From http://technet.microsoft.com/en-us/library/cc776019(WS.10).aspx
|
553
|
-
principal_valid_regex_part = '[^"\/\\\\\[\]\:;|=,+*?<>]+'
|
554
|
-
default :user_valid_regex, [ /^(#{principal_valid_regex_part}\\)?#{principal_valid_regex_part}$/ ]
|
555
|
-
default :group_valid_regex, [ /^(#{principal_valid_regex_part}\\)?#{principal_valid_regex_part}$/ ]
|
556
|
-
|
557
|
-
default :fatal_windows_admin_check, false
|
558
|
-
end
|
559
|
-
|
560
|
-
def self.set_defaults_for_nix
|
561
|
-
# Those lists of regular expressions define what chef considers a
|
562
|
-
# valid user and group name
|
563
|
-
#
|
564
|
-
# user/group cannot start with '-', '+' or '~'
|
565
|
-
# user/group cannot contain ':', ',' or non-space-whitespace or null byte
|
566
|
-
# everything else is allowed (UTF-8, spaces, etc) and we delegate to your O/S useradd program to barf or not
|
567
|
-
# copies: http://anonscm.debian.org/viewvc/pkg-shadow/debian/trunk/debian/patches/506_relaxed_usernames?view=markup
|
568
|
-
default :user_valid_regex, [ /^[^-+~:,\t\r\n\f\0]+[^:,\t\r\n\f\0]*$/ ]
|
569
|
-
default :group_valid_regex, [ /^[^-+~:,\t\r\n\f\0]+[^:,\t\r\n\f\0]*$/ ]
|
570
|
-
end
|
571
|
-
|
572
|
-
# Those lists of regular expressions define what chef considers a
|
573
|
-
# valid user and group name
|
574
|
-
if Chef::Platform.windows?
|
575
|
-
set_defaults_for_windows
|
576
|
-
else
|
577
|
-
set_defaults_for_nix
|
578
|
-
end
|
579
|
-
|
580
|
-
# This provides a hook which rspec can stub so that we can avoid twiddling
|
581
|
-
# global state in tests.
|
582
|
-
def self.env
|
583
|
-
ENV
|
584
|
-
end
|
585
|
-
|
586
|
-
def self.windows_home_path
|
587
|
-
Chef::Log.deprecation("Chef::Config.windows_home_path is now deprecated. Consider using Chef::Util::PathHelper.home instead.")
|
588
|
-
PathHelper.home
|
589
|
-
end
|
590
|
-
|
591
|
-
# returns a platform specific path to the user home dir if set, otherwise default to current directory.
|
592
|
-
default( :user_home ) { PathHelper.home || Dir.pwd }
|
593
|
-
|
594
|
-
# Enable file permission fixup for selinux. Fixup will be done
|
595
|
-
# only if selinux is enabled in the system.
|
596
|
-
default :enable_selinux_file_permission_fixup, true
|
597
|
-
|
598
|
-
# Use atomic updates (i.e. move operation) while updating contents
|
599
|
-
# of the files resources. When set to false copy operation is
|
600
|
-
# used to update files.
|
601
|
-
default :file_atomic_update, true
|
602
|
-
|
603
|
-
# There are 3 possible values for this configuration setting.
|
604
|
-
# true => file staging is done in the destination directory
|
605
|
-
# false => file staging is done via tempfiles under ENV['TMP']
|
606
|
-
# :auto => file staging will try using destination directory if possible and
|
607
|
-
# will fall back to ENV['TMP'] if destination directory is not usable.
|
608
|
-
default :file_staging_uses_destdir, :auto
|
609
|
-
|
610
|
-
# Exit if another run is in progress and the chef-client is unable to
|
611
|
-
# get the lock before time expires. If nil, no timeout is enforced. (Exits
|
612
|
-
# immediately if 0.)
|
613
|
-
default :run_lock_timeout, nil
|
614
|
-
|
615
|
-
# Number of worker threads for syncing cookbooks in parallel. Increasing
|
616
|
-
# this number can result in gateway errors from the server (namely 503 and 504).
|
617
|
-
# If you are seeing this behavior while using the default setting, reducing
|
618
|
-
# the number of threads will help.
|
619
|
-
default :cookbook_sync_threads, 10
|
620
|
-
|
621
|
-
# At the beginning of the Chef Client run, the cookbook manifests are downloaded which
|
622
|
-
# contain URLs for every file in every relevant cookbook. Most of the files
|
623
|
-
# (recipes, resources, providers, libraries, etc) are immediately synchronized
|
624
|
-
# at the start of the run. The handling of "files" and "templates" directories,
|
625
|
-
# however, have two modes of operation. They can either all be downloaded immediately
|
626
|
-
# at the start of the run (no_lazy_load==true) or else they can be lazily loaded as
|
627
|
-
# cookbook_file or template resources are converged which require them (no_lazy_load==false).
|
628
|
-
#
|
629
|
-
# The advantage of lazily loading these files is that unnecessary files are not
|
630
|
-
# synchronized. This may be useful to users with large files checked into cookbooks which
|
631
|
-
# are only selectively downloaded to a subset of clients which use the cookbook. However,
|
632
|
-
# better solutions are to either isolate large files into individual cookbooks and only
|
633
|
-
# include those cookbooks in the run lists of the servers that need them -- or move to
|
634
|
-
# using remote_file and a more appropriate backing store like S3 for large file
|
635
|
-
# distribution.
|
636
|
-
#
|
637
|
-
# The disadvantages of lazily loading files are that users some time find it
|
638
|
-
# confusing that their cookbooks are not fully synchronzied to the cache initially,
|
639
|
-
# and more importantly the time-sensitive URLs which are in the manifest may time
|
640
|
-
# out on long Chef runs before the resource that uses the file is converged
|
641
|
-
# (leading to many confusing 403 errors on template/cookbook_file resources).
|
642
|
-
#
|
643
|
-
default :no_lazy_load, true
|
644
|
-
|
645
|
-
# Default for the chef_gem compile_time attribute. Nil is the same as true but will emit
|
646
|
-
# warnings on every use of chef_gem prompting the user to be explicit. If the user sets this to
|
647
|
-
# true then the user will get backcompat behavior but with a single nag warning that cookbooks
|
648
|
-
# may break with this setting in the future. The false setting is the recommended setting and
|
649
|
-
# will become the default.
|
650
|
-
default :chef_gem_compile_time, nil
|
651
|
-
|
652
|
-
# A whitelisted array of attributes you want sent over the wire when node
|
653
|
-
# data is saved.
|
654
|
-
# The default setting is nil, which collects all data. Setting to [] will not
|
655
|
-
# collect any data for save.
|
656
|
-
default :automatic_attribute_whitelist, nil
|
657
|
-
default :default_attribute_whitelist, nil
|
658
|
-
default :normal_attribute_whitelist, nil
|
659
|
-
default :override_attribute_whitelist, nil
|
660
|
-
|
661
|
-
config_context :windows_service do
|
662
|
-
# Set `watchdog_timeout` to the number of seconds to wait for a chef-client run
|
663
|
-
# to finish
|
664
|
-
default :watchdog_timeout, 2 * (60 * 60) # 2 hours
|
665
|
-
end
|
666
|
-
|
667
|
-
# Chef requires an English-language UTF-8 locale to function properly. We attempt
|
668
|
-
# to use the 'locale -a' command and search through a list of preferences until we
|
669
|
-
# find one that we can use. On Ubuntu systems we should find 'C.UTF-8' and be
|
670
|
-
# able to use that even if there is no English locale on the server, but Mac, Solaris,
|
671
|
-
# AIX, etc do not have that locale. We then try to find an English locale and fall
|
672
|
-
# back to 'C' if we do not. The choice of fallback is pick-your-poison. If we try
|
673
|
-
# to do the work to return a non-US UTF-8 locale then we fail inside of providers when
|
674
|
-
# things like 'svn info' return Japanese and we can't parse them. OTOH, if we pick 'C' then
|
675
|
-
# we will blow up on UTF-8 characters. Between the warn we throw and the Encoding
|
676
|
-
# exception that ruby will throw it is more obvious what is broken if we drop UTF-8 by
|
677
|
-
# default rather than drop English.
|
678
|
-
#
|
679
|
-
# If there is no 'locale -a' then we return 'en_US.UTF-8' since that is the most commonly
|
680
|
-
# available English UTF-8 locale. However, all modern POSIXen should support 'locale -a'.
|
681
|
-
def self.guess_internal_locale
|
682
|
-
# https://github.com/opscode/chef/issues/2181
|
683
|
-
# Some systems have the `locale -a` command, but the result has
|
684
|
-
# invalid characters for the default encoding.
|
685
|
-
#
|
686
|
-
# For example, on CentOS 6 with ENV['LANG'] = "en_US.UTF-8",
|
687
|
-
# `locale -a`.split fails with ArgumentError invalid UTF-8 encoding.
|
688
|
-
locales = shell_out_with_systems_locale!("locale -a").stdout.split
|
689
|
-
case
|
690
|
-
when locales.include?('C.UTF-8')
|
691
|
-
'C.UTF-8'
|
692
|
-
when locales.include?('en_US.UTF-8'), locales.include?('en_US.utf8')
|
693
|
-
'en_US.UTF-8'
|
694
|
-
when locales.include?('en.UTF-8')
|
695
|
-
'en.UTF-8'
|
696
|
-
else
|
697
|
-
# Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8
|
698
|
-
guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i }
|
699
|
-
unless guesses.empty?
|
700
|
-
guessed_locale = guesses.first
|
701
|
-
# Transform into the form en_ZZ.UTF-8
|
702
|
-
guessed_locale.gsub(/UTF-?8$/i, "UTF-8")
|
703
|
-
else
|
704
|
-
Chef::Log.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support."
|
705
|
-
'C'
|
706
|
-
end
|
707
|
-
end
|
708
|
-
rescue
|
709
|
-
if Chef::Platform.windows?
|
710
|
-
Chef::Log.debug "Defaulting to locale en_US.UTF-8 on Windows, until it matters that we do something else."
|
711
|
-
else
|
712
|
-
Chef::Log.debug "No usable locale -a command found, assuming you have en_US.UTF-8 installed."
|
713
|
-
end
|
714
|
-
'en_US.UTF-8'
|
715
|
-
end
|
716
|
-
|
717
|
-
default :internal_locale, guess_internal_locale
|
718
|
-
|
719
|
-
# Force UTF-8 Encoding, for when we fire up in the 'C' locale or other strange locales (e.g.
|
720
|
-
# japanese windows encodings). If we do not do this, then knife upload will fail when a cookbook's
|
721
|
-
# README.md has UTF-8 characters that do not encode in whatever surrounding encoding we have been
|
722
|
-
# passed. Effectively, the Chef Ecosystem is globally UTF-8 by default. Anyone who wants to be
|
723
|
-
# able to upload Shift_JIS or ISO-8859-1 files needs to mark *those* files explicitly with
|
724
|
-
# magic tags to make ruby correctly identify the encoding being used. Changing this default will
|
725
|
-
# break Chef community cookbooks and is very highly discouraged.
|
726
|
-
default :ruby_encoding, Encoding::UTF_8
|
727
|
-
|
728
|
-
# If installed via an omnibus installer, this gives the path to the
|
729
|
-
# "embedded" directory which contains all of the software packaged with
|
730
|
-
# omnibus. This is used to locate the cacert.pem file on windows.
|
731
|
-
def self.embedded_dir
|
732
|
-
Pathname.new(_this_file).ascend do |path|
|
733
|
-
if path.basename.to_s == "embedded"
|
734
|
-
return path.to_s
|
735
|
-
end
|
736
|
-
end
|
737
|
-
|
738
|
-
nil
|
739
|
-
end
|
740
|
-
|
741
|
-
# Path to this file in the current install.
|
742
|
-
def self._this_file
|
743
|
-
File.expand_path(__FILE__)
|
744
|
-
end
|
745
52
|
end
|
746
53
|
end
|
54
|
+
|