chef 11.14.0.alpha.3-x86-mingw32 → 11.14.0.alpha.4-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/CONTRIBUTING.md +140 -99
- data/lib/chef/application.rb +80 -2
- data/lib/chef/application/apply.rb +1 -0
- data/lib/chef/application/client.rb +5 -0
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/application/windows_service.rb +1 -0
- data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +6 -4
- data/lib/chef/config.rb +5 -3
- data/lib/chef/exceptions.rb +2 -0
- data/lib/chef/http/basic_client.rb +1 -0
- data/lib/chef/knife.rb +1 -0
- data/lib/chef/platform/provider_mapping.rb +7 -0
- data/lib/chef/provider/env/windows.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +1 -1
- data/lib/chef/provider/mount/solaris.rb +233 -0
- data/lib/chef/provider/package/apt.rb +9 -0
- data/lib/chef/provider/package/windows.rb +3 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource/mount.rb +6 -1
- data/lib/chef/util/path_helper.rb +94 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/application_spec.rb +58 -0
- data/spec/functional/resource/mount_spec.rb +14 -11
- data/spec/integration/client/client_spec.rb +11 -0
- data/spec/integration/knife/common_options_spec.rb +9 -0
- data/spec/unit/application_spec.rb +157 -0
- data/spec/unit/http/basic_client_spec.rb +42 -0
- data/spec/unit/provider/env/windows_spec.rb +67 -0
- data/spec/unit/provider/group/usermod_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +3 -3
- data/spec/unit/provider/mount/solaris_spec.rb +646 -0
- data/spec/unit/provider/package/apt_spec.rb +5 -0
- data/spec/unit/provider/package/windows_spec.rb +6 -0
- data/spec/unit/resource_reporter_spec.rb +2 -2
- data/spec/unit/util/path_helper_spec.rb +136 -0
- metadata +23 -16
@@ -211,6 +211,7 @@ class Chef
|
|
211
211
|
def reconfigure(startup_parameters=[])
|
212
212
|
configure_chef startup_parameters
|
213
213
|
configure_logging
|
214
|
+
configure_proxy_environment_variables
|
214
215
|
|
215
216
|
Chef::Config[:chef_server_url] = config[:chef_server_url] if config.has_key? :chef_server_url
|
216
217
|
unless Chef::Config[:exception_handlers].any? {|h| Chef::Handler::ErrorReport === h}
|
@@ -195,13 +195,15 @@ class Chef
|
|
195
195
|
process_one
|
196
196
|
end
|
197
197
|
end
|
198
|
-
|
199
|
-
# If
|
200
|
-
#
|
201
|
-
#
|
198
|
+
rescue
|
199
|
+
# If we exited early, perhaps due to any? finding a result, we want
|
200
|
+
# to make sure and throw away any extra results (gracefully) so that
|
201
|
+
# the next enumerator can start over.
|
202
202
|
if !finished?
|
203
203
|
stop
|
204
204
|
end
|
205
|
+
raise
|
206
|
+
ensure
|
205
207
|
@each_running = false
|
206
208
|
end
|
207
209
|
end
|
data/lib/chef/config.rb
CHANGED
@@ -324,8 +324,8 @@ class Chef
|
|
324
324
|
config_context :chef_zero do
|
325
325
|
config_strict_mode true
|
326
326
|
default(:enabled) { Chef::Config.local_mode }
|
327
|
-
default :port, 8889
|
328
327
|
default :host, 'localhost'
|
328
|
+
default :port, 8889
|
329
329
|
end
|
330
330
|
default :chef_server_url, "https://localhost:443"
|
331
331
|
|
@@ -363,8 +363,10 @@ class Chef
|
|
363
363
|
|
364
364
|
# Whether or not to verify the SSL cert for HTTPS requests to the Chef
|
365
365
|
# server API. If set to `true`, the server's cert will be validated
|
366
|
-
# regardless of the :ssl_verify_mode setting.
|
367
|
-
|
366
|
+
# regardless of the :ssl_verify_mode setting. This is set to `true` when
|
367
|
+
# running in local-mode.
|
368
|
+
# NOTE: This is a workaround until verify_peer is enabled by default.
|
369
|
+
default(:verify_api_cert) { Chef::Config.local_mode }
|
368
370
|
|
369
371
|
# Path to the default CA bundle files.
|
370
372
|
default :ssl_ca_path, nil
|
data/lib/chef/exceptions.rb
CHANGED
data/lib/chef/knife.rb
CHANGED
@@ -394,6 +394,7 @@ class Chef
|
|
394
394
|
if Chef::Config.local_mode && !Chef::Config.has_key?(:cookbook_path) && !Chef::Config.has_key?(:chef_repo_path)
|
395
395
|
Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
|
396
396
|
end
|
397
|
+
Chef::Config.chef_zero.host = config[:chef_zero_host] if config[:chef_zero_host]
|
397
398
|
Chef::Config.chef_zero.port = config[:chef_zero_port] if config[:chef_zero_port]
|
398
399
|
|
399
400
|
# Expand a relative path from the config directory. Config from command
|
@@ -276,6 +276,7 @@ class Chef
|
|
276
276
|
:solaris => {},
|
277
277
|
:openindiana => {
|
278
278
|
:default => {
|
279
|
+
:mount => Chef::Provider::Mount::Solaris,
|
279
280
|
:service => Chef::Provider::Service::Solaris,
|
280
281
|
:package => Chef::Provider::Package::Ips,
|
281
282
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -284,6 +285,7 @@ class Chef
|
|
284
285
|
},
|
285
286
|
:opensolaris => {
|
286
287
|
:default => {
|
288
|
+
:mount => Chef::Provider::Mount::Solaris,
|
287
289
|
:service => Chef::Provider::Service::Solaris,
|
288
290
|
:package => Chef::Provider::Package::Ips,
|
289
291
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -292,6 +294,7 @@ class Chef
|
|
292
294
|
},
|
293
295
|
:nexentacore => {
|
294
296
|
:default => {
|
297
|
+
:mount => Chef::Provider::Mount::Solaris,
|
295
298
|
:service => Chef::Provider::Service::Solaris,
|
296
299
|
:package => Chef::Provider::Package::Solaris,
|
297
300
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -300,6 +303,7 @@ class Chef
|
|
300
303
|
},
|
301
304
|
:omnios => {
|
302
305
|
:default => {
|
306
|
+
:mount => Chef::Provider::Mount::Solaris,
|
303
307
|
:service => Chef::Provider::Service::Solaris,
|
304
308
|
:package => Chef::Provider::Package::Ips,
|
305
309
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -309,6 +313,7 @@ class Chef
|
|
309
313
|
},
|
310
314
|
:solaris2 => {
|
311
315
|
:default => {
|
316
|
+
:mount => Chef::Provider::Mount::Solaris,
|
312
317
|
:service => Chef::Provider::Service::Solaris,
|
313
318
|
:package => Chef::Provider::Package::Ips,
|
314
319
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -316,6 +321,7 @@ class Chef
|
|
316
321
|
:user => Chef::Provider::User::Solaris,
|
317
322
|
},
|
318
323
|
"< 5.11" => {
|
324
|
+
:mount => Chef::Provider::Mount::Solaris,
|
319
325
|
:service => Chef::Provider::Service::Solaris,
|
320
326
|
:package => Chef::Provider::Package::Solaris,
|
321
327
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -325,6 +331,7 @@ class Chef
|
|
325
331
|
},
|
326
332
|
:smartos => {
|
327
333
|
:default => {
|
334
|
+
:mount => Chef::Provider::Mount::Solaris,
|
328
335
|
:service => Chef::Provider::Service::Solaris,
|
329
336
|
:package => Chef::Provider::Package::SmartOS,
|
330
337
|
:cron => Chef::Provider::Cron::Solaris,
|
@@ -34,6 +34,7 @@ class Chef
|
|
34
34
|
end
|
35
35
|
obj.variablevalue = @new_resource.value
|
36
36
|
obj.put_
|
37
|
+
ENV[@new_resource.key_name] = @new_resource.value
|
37
38
|
broadcast_env_change
|
38
39
|
end
|
39
40
|
|
@@ -41,6 +42,7 @@ class Chef
|
|
41
42
|
obj = env_obj(@new_resource.key_name)
|
42
43
|
if obj
|
43
44
|
obj.delete_
|
45
|
+
ENV.delete(@new_resource.key_name)
|
44
46
|
broadcast_env_change
|
45
47
|
end
|
46
48
|
end
|
@@ -0,0 +1,233 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Hugo Fichter
|
3
|
+
# Author:: Lamont Granquist (<lamont@getchef.com>)
|
4
|
+
# Author:: Joshua Timberman (<joshua@getchef.com>)
|
5
|
+
# Copyright:: Copyright (c) 2009-2014 Chef Software, Inc
|
6
|
+
# License:: Apache License, Version 2.0
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'chef/provider/mount'
|
22
|
+
require 'chef/log'
|
23
|
+
require 'chef/mixin/shell_out'
|
24
|
+
require 'forwardable'
|
25
|
+
|
26
|
+
class Chef
|
27
|
+
class Provider
|
28
|
+
class Mount
|
29
|
+
class Solaris < Chef::Provider::Mount
|
30
|
+
include Chef::Mixin::ShellOut
|
31
|
+
extend Forwardable
|
32
|
+
|
33
|
+
VFSTAB = "/etc/vfstab".freeze
|
34
|
+
|
35
|
+
def_delegator :@new_resource, :device, :device
|
36
|
+
def_delegator :@new_resource, :device_type, :device_type
|
37
|
+
def_delegator :@new_resource, :dump, :dump
|
38
|
+
def_delegator :@new_resource, :fstype, :fstype
|
39
|
+
def_delegator :@new_resource, :mount_point, :mount_point
|
40
|
+
def_delegator :@new_resource, :options, :options
|
41
|
+
def_delegator :@new_resource, :pass, :pass
|
42
|
+
|
43
|
+
def load_current_resource
|
44
|
+
@current_resource = Chef::Resource::Mount.new(new_resource.name)
|
45
|
+
current_resource.mount_point(mount_point)
|
46
|
+
current_resource.device(device)
|
47
|
+
current_resource.device_type(device_type)
|
48
|
+
update_current_resource_state
|
49
|
+
end
|
50
|
+
|
51
|
+
def define_resource_requirements
|
52
|
+
requirements.assert(:mount, :remount) do |a|
|
53
|
+
a.assertion { !device_should_exist? || ::File.exist?(device) }
|
54
|
+
a.failure_message(Chef::Exceptions::Mount, "Device #{device} does not exist")
|
55
|
+
a.whyrun("Assuming device #{device} would have been created")
|
56
|
+
end
|
57
|
+
|
58
|
+
requirements.assert(:mount, :remount) do |a|
|
59
|
+
a.assertion { ::File.exist?(mount_point) }
|
60
|
+
a.failure_message(Chef::Exceptions::Mount, "Mount point #{mount_point} does not exist")
|
61
|
+
a.whyrun("Assuming mount point #{mount_point} would have been created")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def mount_fs
|
66
|
+
actual_options = options || []
|
67
|
+
actual_options.delete("noauto")
|
68
|
+
command = "mount -F #{fstype}"
|
69
|
+
command << " -o #{actual_options.join(',')}" unless actual_options.empty?
|
70
|
+
command << " #{device} #{mount_point}"
|
71
|
+
shell_out!(command)
|
72
|
+
end
|
73
|
+
|
74
|
+
def umount_fs
|
75
|
+
shell_out!("umount #{mount_point}")
|
76
|
+
end
|
77
|
+
|
78
|
+
def remount_fs
|
79
|
+
# FIXME: what about options like "-o remount,logging" to enable logging on a UFS device?
|
80
|
+
shell_out!("mount -o remount #{mount_point}")
|
81
|
+
end
|
82
|
+
|
83
|
+
def enable_fs
|
84
|
+
if !mount_options_unchanged?
|
85
|
+
# we are enabling because our options have changed, so disable first then re-enable.
|
86
|
+
# XXX: this should be refactored to be the responsibility of the caller
|
87
|
+
disable_fs if current_resource.enabled
|
88
|
+
end
|
89
|
+
|
90
|
+
auto = options.nil? || ! options.include?("noauto")
|
91
|
+
actual_options = unless options.nil?
|
92
|
+
options.delete("noauto")
|
93
|
+
options
|
94
|
+
end
|
95
|
+
|
96
|
+
autostr = auto ? 'yes' : 'no'
|
97
|
+
passstr = pass == 0 ? "-" : pass
|
98
|
+
optstr = (actual_options.nil? || actual_options.empty?) ? "-" : actual_options.join(',')
|
99
|
+
|
100
|
+
etc_tempfile do |f|
|
101
|
+
f.write(IO.read(VFSTAB).chomp)
|
102
|
+
f.puts("\n#{device}\t-\t#{mount_point}\t#{fstype}\t#{passstr}\t#{autostr}\t#{optstr}")
|
103
|
+
f.close
|
104
|
+
# move, preserving modes of destination file
|
105
|
+
mover = Chef::FileContentManagement::Deploy.strategy(true)
|
106
|
+
mover.deploy(f.path, VFSTAB)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
def disable_fs
|
112
|
+
contents = []
|
113
|
+
|
114
|
+
found = false
|
115
|
+
::File.readlines(VFSTAB).reverse_each do |line|
|
116
|
+
if !found && line =~ /^#{device_regex}\s+\S+\s+#{Regexp.escape(mount_point)}/
|
117
|
+
found = true
|
118
|
+
Chef::Log.debug("#{new_resource} is removed from vfstab")
|
119
|
+
next
|
120
|
+
end
|
121
|
+
contents << line
|
122
|
+
end
|
123
|
+
|
124
|
+
if found
|
125
|
+
etc_tempfile do |f|
|
126
|
+
f.write(contents.reverse.join(''))
|
127
|
+
f.close
|
128
|
+
# move, preserving modes of destination file
|
129
|
+
mover = Chef::FileContentManagement::Deploy.strategy(true)
|
130
|
+
mover.deploy(f.path, VFSTAB)
|
131
|
+
end
|
132
|
+
else
|
133
|
+
# this is likely some kind of internal error, since we should only call disable_fs when there
|
134
|
+
# the filesystem we want to disable is enabled.
|
135
|
+
Chef::Log.warn("#{new_resource} did not find the mountpoint to disable in the vfstab")
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def etc_tempfile
|
140
|
+
yield Tempfile.open("vfstab", "/etc")
|
141
|
+
end
|
142
|
+
|
143
|
+
def mount_options_unchanged?
|
144
|
+
current_resource.fstype == fstype and
|
145
|
+
current_resource.options == options and
|
146
|
+
current_resource.dump == dump and
|
147
|
+
current_resource.pass == pass
|
148
|
+
end
|
149
|
+
|
150
|
+
def update_current_resource_state
|
151
|
+
current_resource.mounted(mounted?)
|
152
|
+
( enabled, fstype, options, pass ) = read_vfstab_status
|
153
|
+
current_resource.enabled(enabled)
|
154
|
+
current_resource.fstype(fstype)
|
155
|
+
current_resource.options(options)
|
156
|
+
current_resource.pass(pass)
|
157
|
+
end
|
158
|
+
|
159
|
+
def enabled?
|
160
|
+
read_vfstab_status[0]
|
161
|
+
end
|
162
|
+
|
163
|
+
def mounted?
|
164
|
+
mounted = false
|
165
|
+
shell_out!("mount -v").stdout.each_line do |line|
|
166
|
+
# <device> on <mountpoint> type <fstype> <options> on <date>
|
167
|
+
# /dev/dsk/c1t0d0s0 on / type ufs read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=700040 on Tue May 1 11:33:55 2012
|
168
|
+
case line
|
169
|
+
when /^#{device_regex}\s+on\s+#{Regexp.escape(mount_point)}\s+/
|
170
|
+
Chef::Log.debug("Special device #{device} is mounted as #{mount_point}")
|
171
|
+
mounted = true
|
172
|
+
when /^([\/\w]+)\son\s#{Regexp.escape(mount_point)}\s+/
|
173
|
+
Chef::Log.debug("Special device #{$1} is mounted as #{mount_point}")
|
174
|
+
mounted = false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
mounted
|
178
|
+
end
|
179
|
+
|
180
|
+
private
|
181
|
+
|
182
|
+
def read_vfstab_status
|
183
|
+
# Check to see if there is a entry in /etc/vfstab. Last entry for a volume wins.
|
184
|
+
enabled = false
|
185
|
+
fstype = options = pass = nil
|
186
|
+
::File.foreach(VFSTAB) do |line|
|
187
|
+
case line
|
188
|
+
when /^[#\s]/
|
189
|
+
next
|
190
|
+
# solaris /etc/vfstab format:
|
191
|
+
# device device mount FS fsck mount mount
|
192
|
+
# to mount to fsck point type pass at boot options
|
193
|
+
when /^#{device_regex}\s+[-\/\w]+\s+#{Regexp.escape(mount_point)}\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/
|
194
|
+
enabled = true
|
195
|
+
fstype = $1
|
196
|
+
options = $4
|
197
|
+
# Store the 'mount at boot' column from vfstab as the 'noauto' option
|
198
|
+
# in current_resource.options (linux style)
|
199
|
+
if $3 == "yes"
|
200
|
+
if options.nil? || options.empty?
|
201
|
+
options = "noauto"
|
202
|
+
else
|
203
|
+
options += ",noauto"
|
204
|
+
end
|
205
|
+
end
|
206
|
+
pass = ( $2 == "-" ) ? 0 : $2.to_i
|
207
|
+
Chef::Log.debug("Found mount #{device} to #{mount_point} in #{VFSTAB}")
|
208
|
+
next
|
209
|
+
when /^[-\/\w]+\s+[-\/\w]+\s+#{Regexp.escape(mount_point)}\s+/
|
210
|
+
# if we find a mountpoint on top of our mountpoint, then we are not enabled
|
211
|
+
enabled = false
|
212
|
+
Chef::Log.debug("Found conflicting mount point #{mount_point} in #{VFSTAB}")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
[ enabled, fstype, options, pass ]
|
216
|
+
end
|
217
|
+
|
218
|
+
def device_should_exist?
|
219
|
+
!%w{tmpfs nfs ctfs proc mntfs objfs sharefs fd smbfs}.include?(fstype)
|
220
|
+
end
|
221
|
+
|
222
|
+
def device_regex
|
223
|
+
if ::File.symlink?(device)
|
224
|
+
"(?:#{Regexp.escape(device)}|#{Regexp.escape(::File.expand_path(::File.readlink(device),::File.dirname(device)))})"
|
225
|
+
else
|
226
|
+
Regexp.escape(device)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
@@ -37,6 +37,15 @@ class Chef
|
|
37
37
|
@current_resource
|
38
38
|
end
|
39
39
|
|
40
|
+
def define_resource_requirements
|
41
|
+
super
|
42
|
+
|
43
|
+
requirements.assert(:all_actions) do |a|
|
44
|
+
a.assertion { !@new_resource.source }
|
45
|
+
a.failure_message(Chef::Exceptions::Package, 'apt package provider cannot handle source attribute. Use dpkg provider instead')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
def default_release_options
|
41
50
|
# Use apt::Default-Release option only if provider was explicitly defined
|
42
51
|
"-o APT::Default-Release=#{@new_resource.default_release}" if @new_resource.provider && @new_resource.default_release
|
@@ -18,6 +18,7 @@
|
|
18
18
|
|
19
19
|
require 'chef/resource/windows_package'
|
20
20
|
require 'chef/provider/package'
|
21
|
+
require 'chef/util/path_helper'
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
class Provider
|
@@ -32,6 +33,8 @@ class Chef
|
|
32
33
|
|
33
34
|
# load_current_resource is run in Chef::Provider#run_action when not in whyrun_mode?
|
34
35
|
def load_current_resource
|
36
|
+
@new_resource.source(Chef::Util::PathHelper.validate_path(@new_resource.source))
|
37
|
+
|
35
38
|
@current_resource = Chef::Resource::WindowsPackage.new(@new_resource.name)
|
36
39
|
@current_resource.version(package_provider.installed_version)
|
37
40
|
@new_resource.version(package_provider.package_version)
|
data/lib/chef/providers.rb
CHANGED
data/lib/chef/resource/mount.rb
CHANGED
@@ -65,10 +65,15 @@ class Chef
|
|
65
65
|
|
66
66
|
def device_type(arg=nil)
|
67
67
|
real_arg = arg.kind_of?(String) ? arg.to_sym : arg
|
68
|
+
valid_devices = if RUBY_PLATFORM =~ /solaris/i
|
69
|
+
[ :device ]
|
70
|
+
else
|
71
|
+
[ :device, :label, :uuid ]
|
72
|
+
end
|
68
73
|
set_or_return(
|
69
74
|
:device_type,
|
70
75
|
real_arg,
|
71
|
-
:equal_to =>
|
76
|
+
:equal_to => valid_devices
|
72
77
|
)
|
73
78
|
end
|
74
79
|
|