chef 11.14.0.alpha.2-x86-mingw32 → 11.14.0.alpha.3-x86-mingw32
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 +4 -4
- data/bin/chef-service-manager +1 -1
- data/lib/chef/application.rb +8 -2
- data/lib/chef/chef_fs/command_line.rb +4 -4
- data/lib/chef/chef_fs/file_system.rb +3 -3
- data/lib/chef/chef_fs/parallelizer.rb +66 -90
- data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +35 -0
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +279 -0
- data/lib/chef/config.rb +36 -2
- data/lib/chef/cookbook/cookbook_version_loader.rb +0 -1
- data/lib/chef/cookbook/synchronizer.rb +64 -42
- data/lib/chef/cookbook_uploader.rb +4 -25
- data/lib/chef/cookbook_version.rb +12 -11
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +18 -1
- data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -3
- data/lib/chef/knife/bootstrap.rb +23 -1
- data/lib/chef/knife/bootstrap/chef-aix.erb +58 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +16 -13
- data/lib/chef/knife/core/bootstrap_context.rb +25 -1
- data/lib/chef/knife/list.rb +9 -8
- data/lib/chef/knife/serve.rb +44 -0
- data/lib/chef/knife/show.rb +2 -3
- data/lib/chef/knife/ssh.rb +1 -0
- data/lib/chef/mixin/create_path.rb +20 -4
- data/lib/chef/node.rb +19 -3
- data/lib/chef/platform/provider_mapping.rb +0 -1
- data/lib/chef/platform/query_helpers.rb +4 -3
- data/lib/chef/provider/env/windows.rb +10 -3
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/mount.rb +84 -42
- data/lib/chef/provider/package/freebsd/base.rb +92 -0
- data/lib/chef/provider/package/freebsd/pkg.rb +113 -0
- data/lib/chef/provider/package/freebsd/pkgng.rb +80 -0
- data/lib/chef/provider/package/freebsd/port.rb +70 -0
- data/lib/chef/providers.rb +3 -1
- data/lib/chef/resource/chef_gem.rb +2 -1
- data/lib/chef/resource/freebsd_package.rb +39 -3
- data/lib/chef/resource/lwrp_base.rb +2 -2
- data/lib/chef/resource/mount.rb +9 -9
- data/lib/chef/util/threaded_job_queue.rb +61 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +2 -0
- data/lib/chef/whitelist.rb +82 -0
- data/lib/chef/win32/registry.rb +0 -1
- data/lib/chef/win32/version.rb +4 -3
- data/spec/functional/win32/versions_spec.rb +4 -4
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +4 -1
- data/spec/integration/knife/common_options_spec.rb +9 -9
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
- data/spec/integration/knife/deps_spec.rb +3 -0
- data/spec/integration/knife/list_spec.rb +3 -0
- data/spec/integration/knife/raw_spec.rb +5 -2
- data/spec/integration/knife/redirection_spec.rb +4 -1
- data/spec/integration/knife/serve_spec.rb +57 -0
- data/spec/integration/knife/show_spec.rb +3 -0
- data/spec/support/pedant/run_pedant.rb +1 -0
- data/spec/support/platform_helpers.rb +7 -5
- data/spec/support/shared/context/config.rb +21 -0
- data/spec/support/shared/functional/file_resource.rb +52 -0
- data/spec/unit/chef_fs/parallelizer.rb +482 -0
- data/spec/unit/client_spec.rb +4 -2
- data/spec/unit/config_spec.rb +66 -12
- data/spec/unit/knife/bootstrap_spec.rb +6 -0
- data/spec/unit/knife/core/bootstrap_context_spec.rb +31 -1
- data/spec/unit/node_spec.rb +73 -3
- data/spec/unit/provider/mount_spec.rb +102 -79
- data/spec/unit/provider/package/{freebsd_spec.rb → freebsd/pkg_spec.rb} +19 -32
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +155 -0
- data/spec/unit/provider/package/freebsd/port_spec.rb +160 -0
- data/spec/unit/resource/chef_gem_spec.rb +5 -0
- data/spec/unit/resource/freebsd_package_spec.rb +63 -11
- data/spec/unit/resource/mount_spec.rb +11 -0
- data/spec/unit/role_spec.rb +5 -1
- data/spec/unit/run_lock_spec.rb +2 -0
- data/spec/unit/util/threaded_job_queue_spec.rb +51 -0
- data/spec/unit/version/platform_spec.rb +1 -1
- metadata +176 -161
- data/lib/chef/provider/package/freebsd.rb +0 -149
data/lib/chef/config.rb
CHANGED
@@ -142,7 +142,7 @@ class Chef
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
else
|
145
|
-
|
145
|
+
cache_path
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -240,10 +240,28 @@ class Chef
|
|
240
240
|
if local_mode
|
241
241
|
"#{config_dir}local-mode-cache"
|
242
242
|
else
|
243
|
-
platform_specific_path("/var
|
243
|
+
primary_cache_root = platform_specific_path("/var")
|
244
|
+
primary_cache_path = platform_specific_path("/var/chef")
|
245
|
+
# Use /var/chef as the cache path only if that folder exists and we can read and write
|
246
|
+
# into it, or /var exists and we can read and write into it (we'll create /var/chef later).
|
247
|
+
# Otherwise, we'll create .chef under the user's home directory and use that as
|
248
|
+
# the cache path.
|
249
|
+
unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root)
|
250
|
+
secondary_cache_path = File.join(user_home, '.chef')
|
251
|
+
secondary_cache_path.gsub!(File::SEPARATOR, platform_path_separator) # Safety, mainly for Windows...
|
252
|
+
Chef::Log.info("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
|
253
|
+
secondary_cache_path
|
254
|
+
else
|
255
|
+
primary_cache_path
|
256
|
+
end
|
244
257
|
end
|
245
258
|
end
|
246
259
|
|
260
|
+
# Returns true only if the path exists and is readable and writeable for the user.
|
261
|
+
def self.path_accessible?(path)
|
262
|
+
File.exists?(path) && File.readable?(path) && File.writable?(path)
|
263
|
+
end
|
264
|
+
|
247
265
|
# Where cookbook files are stored on the server (by content checksum)
|
248
266
|
default(:checksum_path) { path_join(cache_path, "checksums") }
|
249
267
|
|
@@ -307,6 +325,7 @@ class Chef
|
|
307
325
|
config_strict_mode true
|
308
326
|
default(:enabled) { Chef::Config.local_mode }
|
309
327
|
default :port, 8889
|
328
|
+
default :host, 'localhost'
|
310
329
|
end
|
311
330
|
default :chef_server_url, "https://localhost:443"
|
312
331
|
|
@@ -552,6 +571,21 @@ class Chef
|
|
552
571
|
# immediately if 0.)
|
553
572
|
default :run_lock_timeout, nil
|
554
573
|
|
574
|
+
# Number of worker threads for syncing cookbooks in parallel. Increasing
|
575
|
+
# this number can result in gateway errors from the server (namely 503 and 504).
|
576
|
+
# If you are seeing this behavior while using the default setting, reducing
|
577
|
+
# the number of threads will help.
|
578
|
+
default :cookbook_sync_threads, 10
|
579
|
+
|
580
|
+
# A whitelisted array of attributes you want sent over the wire when node
|
581
|
+
# data is saved.
|
582
|
+
# The default setting is nil, which collects all data. Setting to [] will not
|
583
|
+
# collect any data for save.
|
584
|
+
default :automatic_attribute_whitelist, nil
|
585
|
+
default :default_attribute_whitelist, nil
|
586
|
+
default :normal_attribute_whitelist, nil
|
587
|
+
default :override_attribute_whitelist, nil
|
588
|
+
|
555
589
|
# If installed via an omnibus installer, this gives the path to the
|
556
590
|
# "embedded" directory which contains all of the software packaged with
|
557
591
|
# omnibus. This is used to locate the cacert.pem file on windows.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'chef/client'
|
2
|
+
require 'chef/util/threaded_job_queue'
|
2
3
|
require 'singleton'
|
3
4
|
|
4
5
|
class Chef
|
@@ -56,6 +57,8 @@ class Chef
|
|
56
57
|
# Synchronizes the locally cached copies of cookbooks with the files on the
|
57
58
|
# server.
|
58
59
|
class CookbookSynchronizer
|
60
|
+
CookbookFile = Struct.new(:cookbook, :segment, :manifest_record)
|
61
|
+
|
59
62
|
def initialize(cookbooks_by_name, events)
|
60
63
|
@eager_segments = Chef::CookbookVersion::COOKBOOK_SEGMENTS.dup
|
61
64
|
unless Chef::Config[:no_lazy_load]
|
@@ -87,6 +90,38 @@ class Chef
|
|
87
90
|
@cookbooks_by_name.key?(cookbook_name)
|
88
91
|
end
|
89
92
|
|
93
|
+
def files
|
94
|
+
@files ||= cookbooks.inject([]) do |memo, cookbook|
|
95
|
+
@eager_segments.each do |segment|
|
96
|
+
cookbook.manifest[segment].each do |manifest_record|
|
97
|
+
memo << CookbookFile.new(cookbook, segment, manifest_record)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
memo
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def files_by_cookbook
|
105
|
+
files.group_by { |file| file.cookbook }
|
106
|
+
end
|
107
|
+
|
108
|
+
def files_remaining_by_cookbook
|
109
|
+
@files_remaining_by_cookbook ||= begin
|
110
|
+
files_by_cookbook.inject({}) do |memo, (cookbook, files)|
|
111
|
+
memo[cookbook] = files.size
|
112
|
+
memo
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def mark_file_synced(file)
|
118
|
+
files_remaining_by_cookbook[file.cookbook] -= 1
|
119
|
+
|
120
|
+
if files_remaining_by_cookbook[file.cookbook] == 0
|
121
|
+
@events.synchronized_cookbook(file.cookbook.name)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
90
125
|
# Synchronizes all the cookbooks from the chef-server.
|
91
126
|
#)
|
92
127
|
# === Returns
|
@@ -97,14 +132,19 @@ class Chef
|
|
97
132
|
|
98
133
|
clear_obsoleted_cookbooks
|
99
134
|
|
100
|
-
|
135
|
+
queue = Chef::Util::ThreadedJobQueue.new
|
101
136
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
137
|
+
files.each do |file|
|
138
|
+
queue << lambda do |lock|
|
139
|
+
sync_file(file)
|
140
|
+
lock.synchronize { mark_file_synced(file) }
|
141
|
+
end
|
106
142
|
end
|
107
143
|
|
144
|
+
@events.cookbook_sync_start(cookbook_count)
|
145
|
+
queue.process(Chef::Config[:cookbook_sync_threads])
|
146
|
+
update_cookbook_filenames
|
147
|
+
|
108
148
|
rescue Exception => e
|
109
149
|
@events.cookbook_sync_failed(cookbooks, e)
|
110
150
|
raise
|
@@ -129,61 +169,43 @@ class Chef
|
|
129
169
|
@events.cookbook_clean_complete
|
130
170
|
end
|
131
171
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
def sync_cookbook(cookbook)
|
139
|
-
Chef::Log.debug("Synchronizing cookbook #{cookbook.name} #{cookbook.version}")
|
140
|
-
|
141
|
-
# files and templates are lazily loaded, and will be done later.
|
142
|
-
|
143
|
-
@eager_segments.each do |segment|
|
144
|
-
segment_filenames = Array.new
|
145
|
-
cookbook.manifest[segment].each do |manifest_record|
|
146
|
-
|
147
|
-
cache_filename = sync_file_in_cookbook(cookbook, manifest_record)
|
148
|
-
# make the segment filenames a full path.
|
149
|
-
full_path_cache_filename = cache.load(cache_filename, false)
|
150
|
-
segment_filenames << full_path_cache_filename
|
151
|
-
end
|
172
|
+
def update_cookbook_filenames
|
173
|
+
files_by_cookbook.each do |cookbook, cookbook_files|
|
174
|
+
files_by_segment = cookbook_files.group_by { |file| file.segment }
|
175
|
+
@eager_segments.each do |segment|
|
176
|
+
segment_files = files_by_segment[segment]
|
177
|
+
next unless segment_files
|
152
178
|
|
153
|
-
|
154
|
-
|
155
|
-
cookbook.recipe_filenames = segment_filenames
|
156
|
-
elsif segment.to_sym == :attributes
|
157
|
-
cookbook.attribute_filenames = segment_filenames
|
158
|
-
else
|
159
|
-
cookbook.segment_filenames(segment).replace(segment_filenames)
|
179
|
+
filenames = segment_files.map { |file| file.manifest_record['path'] }
|
180
|
+
cookbook.replace_segment_filenames(segment, filenames)
|
160
181
|
end
|
161
182
|
end
|
162
|
-
@events.synchronized_cookbook(cookbook.name)
|
163
183
|
end
|
164
184
|
|
165
185
|
# Sync an individual file if needed. If there is an up to date copy
|
166
|
-
# locally, nothing is done.
|
186
|
+
# locally, nothing is done. Updates +file+'s manifest with the full path to
|
187
|
+
# the cached file.
|
167
188
|
#
|
168
189
|
# === Arguments
|
169
|
-
#
|
190
|
+
# file<CookbookFile>
|
170
191
|
# === Returns
|
171
|
-
#
|
172
|
-
def
|
173
|
-
cache_filename = File.join("cookbooks", cookbook.name,
|
192
|
+
# Full path to the cached file as a String
|
193
|
+
def sync_file(file)
|
194
|
+
cache_filename = File.join("cookbooks", file.cookbook.name, file.manifest_record['path'])
|
174
195
|
mark_cached_file_valid(cache_filename)
|
175
196
|
|
176
197
|
# If the checksums are different between on-disk (current) and on-server
|
177
198
|
# (remote, per manifest), do the update. This will also execute if there
|
178
199
|
# is no current checksum.
|
179
|
-
if !cached_copy_up_to_date?(cache_filename,
|
180
|
-
download_file(
|
181
|
-
@events.updated_cookbook_file(cookbook.name, cache_filename)
|
200
|
+
if !cached_copy_up_to_date?(cache_filename, file.manifest_record['checksum'])
|
201
|
+
download_file(file.manifest_record['url'], cache_filename)
|
202
|
+
@events.updated_cookbook_file(file.cookbook.name, cache_filename)
|
182
203
|
else
|
183
204
|
Chef::Log.debug("Not storing #{cache_filename}, as the cache is up to date.")
|
184
205
|
end
|
185
206
|
|
186
|
-
|
207
|
+
# Update the manifest with the full path to the cached file
|
208
|
+
file.manifest_record['path'] = cache.load(cache_filename, false)
|
187
209
|
end
|
188
210
|
|
189
211
|
def cached_copy_up_to_date?(local_path, expected_checksum)
|
@@ -7,29 +7,12 @@ require 'chef/digester'
|
|
7
7
|
require 'chef/cookbook_version'
|
8
8
|
require 'chef/cookbook/syntax_check'
|
9
9
|
require 'chef/cookbook/file_system_file_vendor'
|
10
|
+
require 'chef/util/threaded_job_queue'
|
10
11
|
require 'chef/sandbox'
|
11
|
-
require 'thread'
|
12
12
|
|
13
13
|
class Chef
|
14
14
|
class CookbookUploader
|
15
15
|
|
16
|
-
def self.work_queue
|
17
|
-
@work_queue ||= Queue.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.setup_worker_threads(concurrency=10)
|
21
|
-
@worker_threads ||= begin
|
22
|
-
work_queue
|
23
|
-
(1..concurrency).map do
|
24
|
-
Thread.new do
|
25
|
-
loop do
|
26
|
-
work_queue.pop.call
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
16
|
attr_reader :cookbooks
|
34
17
|
attr_reader :path
|
35
18
|
attr_reader :opts
|
@@ -61,8 +44,6 @@ class Chef
|
|
61
44
|
end
|
62
45
|
|
63
46
|
def upload_cookbooks
|
64
|
-
Thread.abort_on_exception = true
|
65
|
-
|
66
47
|
# Syntax Check
|
67
48
|
validate_cookbooks
|
68
49
|
# generate checksums of cookbook files and create a sandbox
|
@@ -77,7 +58,7 @@ class Chef
|
|
77
58
|
|
78
59
|
Chef::Log.info("Uploading files")
|
79
60
|
|
80
|
-
|
61
|
+
queue = Chef::Util::ThreadedJobQueue.new
|
81
62
|
|
82
63
|
checksums_to_upload = Set.new
|
83
64
|
|
@@ -86,15 +67,13 @@ class Chef
|
|
86
67
|
if info['needs_upload'] == true
|
87
68
|
checksums_to_upload << checksum
|
88
69
|
Chef::Log.info("Uploading #{checksum_files[checksum]} (checksum hex = #{checksum}) to #{info['url']}")
|
89
|
-
|
70
|
+
queue << uploader_function_for(checksum_files[checksum], checksum, info['url'], checksums_to_upload)
|
90
71
|
else
|
91
72
|
Chef::Log.debug("#{checksum_files[checksum]} has not changed")
|
92
73
|
end
|
93
74
|
end
|
94
75
|
|
95
|
-
|
96
|
-
sleep 0.1
|
97
|
-
end
|
76
|
+
queue.process(@concurrency)
|
98
77
|
|
99
78
|
sandbox_url = new_sandbox['uri']
|
100
79
|
Chef::Log.debug("Committing sandbox")
|
@@ -20,9 +20,6 @@
|
|
20
20
|
# limitations under the License.
|
21
21
|
|
22
22
|
require 'chef/log'
|
23
|
-
require 'chef/node'
|
24
|
-
require 'chef/resource_definition_list'
|
25
|
-
require 'chef/recipe'
|
26
23
|
require 'chef/cookbook/file_vendor'
|
27
24
|
require 'chef/cookbook/metadata'
|
28
25
|
require 'chef/version_class'
|
@@ -169,14 +166,7 @@ class Chef
|
|
169
166
|
next unless @manifest.has_key?(segment)
|
170
167
|
filenames = @manifest[segment].map{|manifest_record| manifest_record['name']}
|
171
168
|
|
172
|
-
|
173
|
-
self.recipe_filenames = filenames
|
174
|
-
elsif segment == :attributes
|
175
|
-
self.attribute_filenames = filenames
|
176
|
-
else
|
177
|
-
segment_filenames(segment).clear
|
178
|
-
filenames.each { |filename| segment_filenames(segment) << filename }
|
179
|
-
end
|
169
|
+
replace_segment_filenames(segment, filenames)
|
180
170
|
end
|
181
171
|
end
|
182
172
|
|
@@ -272,6 +262,17 @@ class Chef
|
|
272
262
|
end
|
273
263
|
end
|
274
264
|
|
265
|
+
def replace_segment_filenames(segment, filenames)
|
266
|
+
case segment.to_sym
|
267
|
+
when :recipes
|
268
|
+
self.recipe_filenames = filenames
|
269
|
+
when :attributes
|
270
|
+
self.attribute_filenames = filenames
|
271
|
+
else
|
272
|
+
segment_filenames(segment).replace(filenames)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
275
276
|
# Query whether a template file +template_filename+ is available. File
|
276
277
|
# specificity for the given +node+ is obeyed in the lookup.
|
277
278
|
def has_template_for_node?(node, template_filename)
|
@@ -88,7 +88,7 @@ E
|
|
88
88
|
def format_rest_error
|
89
89
|
Array(Chef::JSONCompat.from_json(exception.response.body)["error"]).join('; ')
|
90
90
|
rescue Exception
|
91
|
-
|
91
|
+
safe_format_rest_error
|
92
92
|
end
|
93
93
|
|
94
94
|
def username
|
@@ -107,6 +107,23 @@ E
|
|
107
107
|
exception.response.body =~ /synchronize the clock/i
|
108
108
|
end
|
109
109
|
|
110
|
+
def safe_format_rest_error
|
111
|
+
# When we get 504 from the server, sometimes the response body is non-readable.
|
112
|
+
#
|
113
|
+
# Stack trace:
|
114
|
+
#
|
115
|
+
# NoMethodError: undefined method `closed?' for nil:NilClass
|
116
|
+
# .../lib/ruby/1.9.1/net/http.rb:2789:in `stream_check'
|
117
|
+
# .../lib/ruby/1.9.1/net/http.rb:2709:in `read_body'
|
118
|
+
# .../lib/ruby/1.9.1/net/http.rb:2736:in `body'
|
119
|
+
# .../lib/chef/formatters/error_inspectors/api_error_formatting.rb:91:in `rescue in format_rest_error'
|
120
|
+
begin
|
121
|
+
exception.response.body
|
122
|
+
rescue Exception
|
123
|
+
"Cannot fetch the contents of the response."
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
110
127
|
end
|
111
128
|
end
|
112
129
|
end
|
@@ -65,7 +65,7 @@ class Chef
|
|
65
65
|
when Net::HTTPNotFound
|
66
66
|
when Net::HTTPInternalServerError
|
67
67
|
describe_500_error(error_description)
|
68
|
-
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
|
68
|
+
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable, Net::HTTPGatewayTimeOut
|
69
69
|
describe_503_error(error_description)
|
70
70
|
else
|
71
71
|
describe_http_error(error_description)
|
@@ -76,5 +76,3 @@ class Chef
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -154,6 +154,26 @@ class Chef
|
|
154
154
|
:description => "A file containing the secret key to use to encrypt data bag item values",
|
155
155
|
:proc => Proc.new { |sf| Chef::Config[:knife][:secret_file] = sf }
|
156
156
|
|
157
|
+
option :bootstrap_url,
|
158
|
+
:long => "--bootstrap-url URL",
|
159
|
+
:description => "URL to a custom installation script",
|
160
|
+
:proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
|
161
|
+
|
162
|
+
option :bootstrap_install_command,
|
163
|
+
:long => "--bootstrap-install-command COMMANDS",
|
164
|
+
:description => "Custom command to install chef-client",
|
165
|
+
:proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic }
|
166
|
+
|
167
|
+
option :bootstrap_wget_options,
|
168
|
+
:long => "--bootstrap-wget-options OPTIONS",
|
169
|
+
:description => "Add options to wget when installing chef-client",
|
170
|
+
:proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo }
|
171
|
+
|
172
|
+
option :bootstrap_curl_options,
|
173
|
+
:long => "--bootstrap-curl-options OPTIONS",
|
174
|
+
:description => "Add options to curl when install chef-client",
|
175
|
+
:proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co }
|
176
|
+
|
157
177
|
def find_template(template=nil)
|
158
178
|
# Are we bootstrapping using an already shipped template?
|
159
179
|
if config[:template_file]
|
@@ -206,7 +226,9 @@ class Chef
|
|
206
226
|
begin
|
207
227
|
knife_ssh.run
|
208
228
|
rescue Net::SSH::AuthenticationFailed
|
209
|
-
|
229
|
+
if config[:ssh_password]
|
230
|
+
raise
|
231
|
+
else
|
210
232
|
ui.info("Failed to authenticate #{config[:ssh_user]} - trying password auth")
|
211
233
|
knife_ssh_with_password_auth.run
|
212
234
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
ksh -c '
|
2
|
+
|
3
|
+
function exists {
|
4
|
+
if type $1 >/dev/null 2>&1
|
5
|
+
then
|
6
|
+
return 0
|
7
|
+
else
|
8
|
+
return 1
|
9
|
+
fi
|
10
|
+
}
|
11
|
+
|
12
|
+
if ! exists /usr/bin/chef-client; then
|
13
|
+
<% if @chef_config[:aix_package] -%>
|
14
|
+
# Read the download URL/location from knife.rb with option aix_package
|
15
|
+
rm -rf /tmp/chef_installer # ensure there no older pkg
|
16
|
+
echo "<%= @chef_config[:aix_package] %>"
|
17
|
+
perl -e '\''use LWP::Simple; getprint($ARGV[0]);'\'' <%= @chef_config[:aix_package] %> > /tmp/chef_installer
|
18
|
+
installp -aYF -d /tmp/chef_installer chef
|
19
|
+
<% else -%>
|
20
|
+
echo ":aix_package location is not set in knife.rb"
|
21
|
+
exit
|
22
|
+
<% end -%>
|
23
|
+
fi
|
24
|
+
|
25
|
+
mkdir -p /etc/chef
|
26
|
+
|
27
|
+
cat > /etc/chef/validation.pem <<'EOP'
|
28
|
+
<%= validation_key %>
|
29
|
+
EOP
|
30
|
+
chmod 0600 /etc/chef/validation.pem
|
31
|
+
|
32
|
+
<% if encrypted_data_bag_secret -%>
|
33
|
+
cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
|
34
|
+
<%= encrypted_data_bag_secret %>
|
35
|
+
EOP
|
36
|
+
chmod 0600 /etc/chef/encrypted_data_bag_secret
|
37
|
+
<% end -%>
|
38
|
+
|
39
|
+
<%# Generate Ohai Hints -%>
|
40
|
+
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
|
41
|
+
mkdir -p /etc/chef/ohai/hints
|
42
|
+
|
43
|
+
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
44
|
+
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
45
|
+
<%= hash.to_json %>
|
46
|
+
EOP
|
47
|
+
<% end -%>
|
48
|
+
<% end -%>
|
49
|
+
|
50
|
+
cat > /etc/chef/client.rb <<'EOP'
|
51
|
+
<%= config_content %>
|
52
|
+
EOP
|
53
|
+
|
54
|
+
cat > /etc/chef/first-boot.json <<'EOP'
|
55
|
+
<%= first_boot.to_json %>
|
56
|
+
EOP
|
57
|
+
|
58
|
+
<%= start_chef %>'
|