chef 13.4.19-universal-mingw32 → 13.4.24-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/acceptance/.DS_Store +0 -0
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/provider/package.rb +7 -8
- data/lib/chef/provider/route.rb +26 -7
- data/lib/chef/provider/windows_task.rb +108 -54
- data/lib/chef/util/dsc/local_configuration_manager.rb +17 -7
- data/lib/chef/version.rb +1 -1
- data/spec/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/spec/unit/provider/route_spec.rb +21 -1
- data/spec/unit/provider/windows_task_spec.rb +113 -0
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +60 -8
- data/tasks/.DS_Store +0 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc38e67c085a0869fd08892de0f3edbd5b421303
|
4
|
+
data.tar.gz: 4a46e7292fc04d9f391fe9802d9cfbad8ee51b3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 795ca4d0a9154e23d3106f4759dc3ab788696d6e0e86c9af85cec10846a53bb53ed73251569b4b61406b216e3f2aeda88f2d22ff3504746ec4afd89af623f1ad
|
7
|
+
data.tar.gz: b28bc511db44930de45ac490968ed558f01ba6609502073dc1e8f867e3da3771a7ca9ba31d0e2021c322decdf9f641fe6a30b72f69687de1b9422dd53ba7bad6
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
13.4.
|
1
|
+
13.4.24
|
Binary file
|
data/distro/.DS_Store
ADDED
Binary file
|
data/lib/.DS_Store
CHANGED
Binary file
|
@@ -311,18 +311,19 @@ class Chef
|
|
311
311
|
#
|
312
312
|
# This MUST have 'equality' semantics -- the exact thing matches the exact thing.
|
313
313
|
#
|
314
|
-
# The current_version should probably be dropped out of the method signature, it should
|
315
|
-
# always be the first argument.
|
316
|
-
#
|
317
314
|
# The name is not just bad, but i find it completely misleading, consider:
|
318
315
|
#
|
319
316
|
# target_version_already_installed?(current_version, new_version)
|
320
317
|
# target_version_already_installed?(current_version, candidate_version)
|
321
318
|
#
|
322
|
-
#
|
319
|
+
# Which of those is the 'target_version'? I'd say the new_version and I'm confused when
|
323
320
|
# i see it called with the candidate_version.
|
324
321
|
#
|
325
|
-
# `
|
322
|
+
# `version_equals?(v1, v2)` would be a better name.
|
323
|
+
#
|
324
|
+
# Note that most likely we need a spaceship operator on versions that subclasses can implement
|
325
|
+
# and we should have `version_compare(v1, v2)` that returns `v1 <=> v2`.
|
326
|
+
#
|
326
327
|
def target_version_already_installed?(current_version, target_version)
|
327
328
|
return false unless current_version && target_version
|
328
329
|
current_version == target_version
|
@@ -333,10 +334,8 @@ class Chef
|
|
333
334
|
#
|
334
335
|
# Subclasses MAY override this to provide fuzzy matching on the resource ('>=' and '~>' stuff)
|
335
336
|
#
|
336
|
-
#
|
337
|
-
# removed from the method signature).
|
337
|
+
# `version_satisfied_by?(version, constraint)` might be a better name to make this generic.
|
338
338
|
#
|
339
|
-
# `new_version_satisfied?()` might be a better name
|
340
339
|
def version_requirement_satisfied?(current_version, new_version)
|
341
340
|
target_version_already_installed?(current_version, new_version)
|
342
341
|
end
|
data/lib/chef/provider/route.rb
CHANGED
@@ -86,7 +86,9 @@ class Chef
|
|
86
86
|
self.is_running = false
|
87
87
|
|
88
88
|
# cidr or quad dot mask
|
89
|
-
new_ip = if new_resource.
|
89
|
+
new_ip = if new_resource.target == "default"
|
90
|
+
IPAddr.new(new_resource.gateway)
|
91
|
+
elsif new_resource.netmask
|
90
92
|
IPAddr.new("#{new_resource.target}/#{new_resource.netmask}")
|
91
93
|
else
|
92
94
|
IPAddr.new(new_resource.target)
|
@@ -180,12 +182,29 @@ class Chef
|
|
180
182
|
end
|
181
183
|
end
|
182
184
|
conf.each do |k, v|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
185
|
+
if new_resource.target == "default"
|
186
|
+
network_file_name = "/etc/sysconfig/network"
|
187
|
+
converge_by("write route default route to #{network_file_name}") do
|
188
|
+
Chef::Log.debug("#{new_resource} writing default route #{new_resource.gateway} to #{network_file_name}")
|
189
|
+
if ::File.exists?(network_file_name)
|
190
|
+
network_file = ::Chef::Util::FileEdit.new(network_file_name)
|
191
|
+
network_file.search_file_replace_line /^GATEWAY=/, "GATEWAY=#{new_resource.gateway}"
|
192
|
+
network_file.insert_line_if_no_match /^GATEWAY=/, "GATEWAY=#{new_resource.gateway}"
|
193
|
+
network_file.write_file
|
194
|
+
else
|
195
|
+
network_file = ::File.new(network_file_name, "w")
|
196
|
+
network_file.puts("GATEWAY=#{new_resource.gateway}")
|
197
|
+
network_file.close
|
198
|
+
end
|
199
|
+
end
|
200
|
+
else
|
201
|
+
network_file_name = "/etc/sysconfig/network-scripts/route-#{k}"
|
202
|
+
converge_by("write route route.#{k}\n#{conf[k]} to #{network_file_name}") do
|
203
|
+
network_file = ::File.new(network_file_name, "w")
|
204
|
+
network_file.puts(conf[k])
|
205
|
+
Chef::Log.debug("#{new_resource} writing route.#{k}\n#{conf[k]}")
|
206
|
+
network_file.close
|
207
|
+
end
|
189
208
|
end
|
190
209
|
end
|
191
210
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
11
|
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -30,30 +30,33 @@ class Chef
|
|
30
30
|
provides :windows_task, os: "windows"
|
31
31
|
|
32
32
|
def load_current_resource
|
33
|
-
|
33
|
+
self.current_resource = Chef::Resource::WindowsTask.new(new_resource.name)
|
34
34
|
pathed_task_name = new_resource.task_name.start_with?('\\') ? new_resource.task_name : "\\#{new_resource.task_name}"
|
35
35
|
|
36
|
-
|
36
|
+
current_resource.task_name(pathed_task_name)
|
37
37
|
task_hash = load_task_hash(pathed_task_name)
|
38
38
|
|
39
39
|
set_current_resource(task_hash) if task_hash.respond_to?(:[]) && task_hash[:TaskName] == pathed_task_name
|
40
|
-
|
40
|
+
current_resource
|
41
41
|
end
|
42
42
|
|
43
43
|
def set_current_resource(task_hash)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
current_resource.exists = true
|
45
|
+
current_resource.command(task_hash[:TaskToRun])
|
46
|
+
current_resource.cwd(task_hash[:StartIn]) unless task_hash[:StartIn] == "N/A"
|
47
|
+
current_resource.user(task_hash[:RunAsUser])
|
48
48
|
set_current_run_level task_hash[:run_level]
|
49
49
|
set_current_frequency task_hash
|
50
|
-
|
51
|
-
|
50
|
+
current_resource.day(task_hash[:day]) if task_hash[:day]
|
51
|
+
current_resource.months(task_hash[:months]) if task_hash[:months]
|
52
52
|
set_current_idle_time(task_hash[:idle_time]) if task_hash[:idle_time]
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
current_resource.random_delay(task_hash[:random_delay]) if task_hash[:random_delay]
|
54
|
+
# schtask sets execution_time_limit as PT72H by default
|
55
|
+
current_resource.execution_time_limit(task_hash[:execution_time_limit] || "PT72H")
|
56
|
+
current_resource.status = :running if task_hash[:Status] == "Running"
|
57
|
+
current_resource.enabled = true if task_hash[:ScheduledTaskState] == "Enabled"
|
58
|
+
current_resource.start_time = task_hash[:StartTime] if task_hash[:StartTime]
|
59
|
+
current_resource.start_day = task_hash[:StartDate] if task_hash[:StartDate]
|
57
60
|
end
|
58
61
|
|
59
62
|
# This method checks if task and command attributes exist since those two are mandatory attributes to create a schedules task.
|
@@ -71,7 +74,7 @@ class Chef
|
|
71
74
|
end
|
72
75
|
|
73
76
|
def action_create
|
74
|
-
if
|
77
|
+
if current_resource.exists
|
75
78
|
if !(task_need_update? || new_resource.force)
|
76
79
|
Chef::Log.info "#{new_resource} task already exists - nothing to do"
|
77
80
|
return
|
@@ -79,7 +82,7 @@ class Chef
|
|
79
82
|
# To merge current resource and new resource attributes
|
80
83
|
resource_attributes.each do |attribute|
|
81
84
|
new_resource_attribute = new_resource.send(attribute)
|
82
|
-
current_resource_attribute =
|
85
|
+
current_resource_attribute = current_resource.send(attribute)
|
83
86
|
new_resource.send("#{attribute}=", current_resource_attribute ) if current_resource_attribute && new_resource_attribute.nil?
|
84
87
|
end
|
85
88
|
end
|
@@ -89,7 +92,7 @@ class Chef
|
|
89
92
|
options["SC"] = schedule
|
90
93
|
options["MO"] = new_resource.frequency_modifier if frequency_modifier_allowed
|
91
94
|
options["I"] = new_resource.idle_time unless new_resource.idle_time.nil?
|
92
|
-
options["SD"] = new_resource.start_day unless new_resource.start_day.nil?
|
95
|
+
options["SD"] = convert_user_date_to_system_date new_resource.start_day unless new_resource.start_day.nil?
|
93
96
|
options["ST"] = new_resource.start_time unless new_resource.start_time.nil?
|
94
97
|
options["TR"] = new_resource.command
|
95
98
|
options["RU"] = new_resource.user
|
@@ -110,8 +113,8 @@ class Chef
|
|
110
113
|
end
|
111
114
|
|
112
115
|
def action_run
|
113
|
-
if
|
114
|
-
if
|
116
|
+
if current_resource.exists
|
117
|
+
if current_resource.status == :running
|
115
118
|
Chef::Log.info "#{new_resource} task is currently running, skipping run"
|
116
119
|
else
|
117
120
|
run_schtasks "RUN"
|
@@ -124,7 +127,7 @@ class Chef
|
|
124
127
|
end
|
125
128
|
|
126
129
|
def action_delete
|
127
|
-
if
|
130
|
+
if current_resource.exists
|
128
131
|
# always need to force deletion
|
129
132
|
run_schtasks "DELETE", "F" => ""
|
130
133
|
new_resource.updated_by_last_action true
|
@@ -135,8 +138,8 @@ class Chef
|
|
135
138
|
end
|
136
139
|
|
137
140
|
def action_end
|
138
|
-
if
|
139
|
-
if
|
141
|
+
if current_resource.exists
|
142
|
+
if current_resource.status != :running
|
140
143
|
Chef::Log.debug "#{new_resource} is not running - nothing to do"
|
141
144
|
else
|
142
145
|
run_schtasks "END"
|
@@ -149,8 +152,8 @@ class Chef
|
|
149
152
|
end
|
150
153
|
|
151
154
|
def action_enable
|
152
|
-
if
|
153
|
-
if
|
155
|
+
if current_resource.exists
|
156
|
+
if current_resource.enabled
|
154
157
|
Chef::Log.debug "#{new_resource} already enabled - nothing to do"
|
155
158
|
else
|
156
159
|
run_schtasks "CHANGE", "ENABLE" => ""
|
@@ -164,8 +167,8 @@ class Chef
|
|
164
167
|
end
|
165
168
|
|
166
169
|
def action_disable
|
167
|
-
if
|
168
|
-
if
|
170
|
+
if current_resource.exists
|
171
|
+
if current_resource.enabled
|
169
172
|
run_schtasks "CHANGE", "DISABLE" => ""
|
170
173
|
new_resource.updated_by_last_action true
|
171
174
|
Chef::Log.info "#{new_resource} task disabled"
|
@@ -194,19 +197,20 @@ class Chef
|
|
194
197
|
|
195
198
|
def task_need_update?
|
196
199
|
return true if (new_resource.command &&
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
200
|
+
current_resource.command != new_resource.command.tr("'", '"')) ||
|
201
|
+
current_resource.user != new_resource.user ||
|
202
|
+
current_resource.run_level != new_resource.run_level ||
|
203
|
+
current_resource.cwd != new_resource.cwd ||
|
204
|
+
current_resource.frequency_modifier != new_resource.frequency_modifier ||
|
205
|
+
current_resource.frequency != new_resource.frequency ||
|
206
|
+
current_resource.idle_time != new_resource.idle_time ||
|
207
|
+
current_resource.random_delay != new_resource.random_delay ||
|
208
|
+
!new_resource.execution_time_limit.include?(current_resource.execution_time_limit) ||
|
209
|
+
(new_resource.start_day && start_day_updated?) ||
|
210
|
+
(new_resource.start_time && start_time_updated?)
|
207
211
|
begin
|
208
|
-
return true if new_resource.day.to_s.casecmp(
|
209
|
-
new_resource.months.to_s.casecmp(
|
212
|
+
return true if new_resource.day.to_s.casecmp(current_resource.day.to_s) != 0 ||
|
213
|
+
new_resource.months.to_s.casecmp(current_resource.months.to_s) != 0
|
210
214
|
rescue
|
211
215
|
Chef::Log.debug "caught a raise in task_needs_update?"
|
212
216
|
end
|
@@ -214,6 +218,56 @@ class Chef
|
|
214
218
|
false
|
215
219
|
end
|
216
220
|
|
221
|
+
def start_day_updated?
|
222
|
+
current_day = DateTime.strptime(current_resource.start_day, convert_system_date_format_to_ruby_date_format)
|
223
|
+
new_day = DateTime.parse(new_resource.start_day)
|
224
|
+
current_day != new_day
|
225
|
+
end
|
226
|
+
|
227
|
+
def start_time_updated?
|
228
|
+
time = DateTime.parse(current_resource.start_time).strftime("%H:%M")
|
229
|
+
time != new_resource.start_time
|
230
|
+
end
|
231
|
+
|
232
|
+
def convert_user_date_to_system_date(date_in_string)
|
233
|
+
DateTime.parse(date_in_string).strftime(convert_system_date_format_to_ruby_long_date)
|
234
|
+
end
|
235
|
+
|
236
|
+
def convert_system_date_format_to_ruby_long_date
|
237
|
+
date_format = get_system_short_date_format.dup
|
238
|
+
date_format.sub!("MMM", "%m")
|
239
|
+
common_date_format_conversion(date_format)
|
240
|
+
date_format.sub!("yy", "%Y")
|
241
|
+
date_format
|
242
|
+
end
|
243
|
+
|
244
|
+
def convert_system_date_format_to_ruby_date_format
|
245
|
+
date_format = get_system_short_date_format.dup
|
246
|
+
date_format.sub!("MMM", "%b")
|
247
|
+
common_date_format_conversion(date_format)
|
248
|
+
date_format.sub!("yy", "%y")
|
249
|
+
date_format
|
250
|
+
end
|
251
|
+
|
252
|
+
def common_date_format_conversion(date_format)
|
253
|
+
date_format.sub!("dd", "d")
|
254
|
+
date_format.sub!("d", "%d")
|
255
|
+
date_format.sub!("MM", "%m")
|
256
|
+
date_format.sub!("M", "%m")
|
257
|
+
date_format.sub!("yyyy", "%Y")
|
258
|
+
end
|
259
|
+
|
260
|
+
def get_system_short_date_format
|
261
|
+
return @system_short_date_format if @system_short_date_format
|
262
|
+
Chef::Log.debug "Finding system date format"
|
263
|
+
task_script = <<-EOH
|
264
|
+
[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
|
265
|
+
[Globalization.Cultureinfo]::CurrentCulture.DateTimeFormat.ShortDatePattern
|
266
|
+
EOH
|
267
|
+
@system_short_date_format = powershell_out(task_script).stdout.force_encoding("UTF-8").gsub(/[\s+\uFEFF]/, "")
|
268
|
+
@system_short_date_format
|
269
|
+
end
|
270
|
+
|
217
271
|
def update_task_xml(options = [])
|
218
272
|
# random_delay xml element is different for different frequencies
|
219
273
|
random_delay_xml_element = {
|
@@ -394,9 +448,9 @@ class Chef
|
|
394
448
|
def set_current_run_level(run_level)
|
395
449
|
case run_level
|
396
450
|
when "HighestAvailable"
|
397
|
-
|
451
|
+
current_resource.run_level(:highest)
|
398
452
|
when "LeastPrivilege"
|
399
|
-
|
453
|
+
current_resource.run_level(:limited)
|
400
454
|
end
|
401
455
|
end
|
402
456
|
|
@@ -404,34 +458,34 @@ class Chef
|
|
404
458
|
if task_hash[:repetition_interval]
|
405
459
|
duration = ISO8601::Duration.new(task_hash[:repetition_interval])
|
406
460
|
if task_hash[:repetition_interval].include?("M")
|
407
|
-
|
408
|
-
|
461
|
+
current_resource.frequency(:minute)
|
462
|
+
current_resource.frequency_modifier(duration.minutes.atom.to_i)
|
409
463
|
elsif task_hash[:repetition_interval].include?("H")
|
410
|
-
|
411
|
-
|
464
|
+
current_resource.frequency(:hourly)
|
465
|
+
current_resource.frequency_modifier(duration.hours.atom.to_i)
|
412
466
|
end
|
413
467
|
end
|
414
468
|
|
415
469
|
if task_hash[:schedule_by_day]
|
416
|
-
|
417
|
-
|
470
|
+
current_resource.frequency(:daily)
|
471
|
+
current_resource.frequency_modifier(task_hash[:schedule_by_day].to_i)
|
418
472
|
end
|
419
473
|
|
420
474
|
if task_hash[:schedule_by_week]
|
421
|
-
|
422
|
-
|
475
|
+
current_resource.frequency(:weekly)
|
476
|
+
current_resource.frequency_modifier(task_hash[:schedule_by_week].to_i)
|
423
477
|
end
|
424
478
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
479
|
+
current_resource.frequency(:monthly) if task_hash[:schedule_by_month]
|
480
|
+
current_resource.frequency(:on_logon) if task_hash[:on_logon]
|
481
|
+
current_resource.frequency(:onstart) if task_hash[:onstart]
|
482
|
+
current_resource.frequency(:on_idle) if task_hash[:on_idle]
|
483
|
+
current_resource.frequency(:once) if task_hash[:once]
|
430
484
|
end
|
431
485
|
|
432
486
|
def set_current_idle_time(idle_time)
|
433
487
|
duration = ISO8601::Duration.new(idle_time)
|
434
|
-
|
488
|
+
current_resource.idle_time(duration.minutes.atom.to_i)
|
435
489
|
end
|
436
490
|
|
437
491
|
end
|
@@ -47,15 +47,13 @@ class Chef::Util::DSC
|
|
47
47
|
|
48
48
|
def run_configuration_cmdlet(configuration_document, apply_configuration, shellout_flags)
|
49
49
|
Chef::Log.debug("DSC: Calling DSC Local Config Manager to #{apply_configuration ? "set" : "test"} configuration document.")
|
50
|
-
test_only_parameters = ! apply_configuration ? "-whatif; if (! $?) { exit 1 }" : ""
|
51
50
|
|
52
51
|
start_operation_timing
|
53
|
-
command_code = lcm_command_code(@configuration_path, test_only_parameters)
|
54
52
|
status = nil
|
55
53
|
|
56
54
|
begin
|
57
55
|
save_configuration_document(configuration_document)
|
58
|
-
cmdlet = ::Chef::Util::Powershell::Cmdlet.new(@node,
|
56
|
+
cmdlet = ::Chef::Util::Powershell::Cmdlet.new(@node, lcm_command(apply_configuration))
|
59
57
|
if apply_configuration
|
60
58
|
status = cmdlet.run!({}, shellout_flags)
|
61
59
|
else
|
@@ -72,10 +70,22 @@ class Chef::Util::DSC
|
|
72
70
|
status
|
73
71
|
end
|
74
72
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
def lcm_command(apply_configuration)
|
74
|
+
common_command_prefix = "$ProgressPreference = 'SilentlyContinue';"
|
75
|
+
ps4_base_command = "#{common_command_prefix} Start-DscConfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force"
|
76
|
+
if apply_configuration
|
77
|
+
ps4_base_command
|
78
|
+
else
|
79
|
+
if ps_version_gte_5?
|
80
|
+
"#{common_command_prefix} Test-DscConfiguration -path #{@configuration_path}"
|
81
|
+
else
|
82
|
+
ps4_base_command + " -whatif; if (! $?) { exit 1 }"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def ps_version_gte_5?
|
88
|
+
Chef::Platform.supported_powershell_version?(@node, 5)
|
79
89
|
end
|
80
90
|
|
81
91
|
def log_what_if_exception(what_if_exception_output)
|
data/lib/chef/version.rb
CHANGED
data/spec/.DS_Store
CHANGED
Binary file
|
data/spec/unit/.DS_Store
CHANGED
Binary file
|
@@ -29,9 +29,14 @@ describe Chef::Provider::Route do
|
|
29
29
|
@new_resource.gateway "10.0.0.9"
|
30
30
|
@current_resource = Chef::Resource::Route.new("10.0.0.10")
|
31
31
|
@current_resource.gateway "10.0.0.9"
|
32
|
+
@default_resource = Chef::Resource::Route.new("default")
|
33
|
+
@default_resource.gateway "10.0.0.9"
|
32
34
|
|
33
35
|
@provider = Chef::Provider::Route.new(@new_resource, @run_context)
|
34
36
|
@provider.current_resource = @current_resource
|
37
|
+
|
38
|
+
@default_provider = Chef::Provider::Route.new(@default_resource, @run_context)
|
39
|
+
@default_provider.current_resource = @default_resource
|
35
40
|
end
|
36
41
|
|
37
42
|
describe Chef::Provider::Route, "hex2ip" do
|
@@ -161,6 +166,11 @@ describe Chef::Provider::Route do
|
|
161
166
|
@new_resource.gateway(nil)
|
162
167
|
expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
|
163
168
|
end
|
169
|
+
|
170
|
+
it "should use the gatway when target is default" do
|
171
|
+
@default_resource.gateway("10.0.0.10")
|
172
|
+
expect(@default_provider.generate_command(:add).join(" ")).to match(/10.0.0.10/)
|
173
|
+
end
|
164
174
|
end
|
165
175
|
|
166
176
|
describe Chef::Provider::Route, "generate_command for action_delete" do
|
@@ -216,10 +226,20 @@ describe Chef::Provider::Route do
|
|
216
226
|
|
217
227
|
route_file = StringIO.new
|
218
228
|
expect(File).to receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file)
|
219
|
-
# Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n")
|
220
229
|
@run_context.resource_collection << @new_resource
|
221
230
|
@provider.generate_config
|
222
231
|
end
|
232
|
+
|
233
|
+
end
|
234
|
+
%w{ centos redhat fedora }.each do |platform|
|
235
|
+
it "should write a default route file on #{platform} platform" do
|
236
|
+
@node.automatic_attrs[:platform] = platform
|
237
|
+
|
238
|
+
route_file = StringIO.new
|
239
|
+
expect(File).to receive(:new).with("/etc/sysconfig/network", "w").and_return(route_file)
|
240
|
+
@run_context.resource_collection << @default_resource
|
241
|
+
@default_provider.generate_config
|
242
|
+
end
|
223
243
|
end
|
224
244
|
|
225
245
|
it "should put all routes for a device in a route config file" do
|
@@ -322,6 +322,7 @@ describe Chef::Provider::WindowsTask do
|
|
322
322
|
context "when the task exists" do
|
323
323
|
before do
|
324
324
|
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
325
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("MM/dd/yyyy")
|
325
326
|
provider.load_current_resource
|
326
327
|
|
327
328
|
new_resource.command "chef-client"
|
@@ -330,6 +331,8 @@ describe Chef::Provider::WindowsTask do
|
|
330
331
|
new_resource.frequency_modifier 15
|
331
332
|
new_resource.user "SYSTEM"
|
332
333
|
new_resource.execution_time_limit "PT72H"
|
334
|
+
new_resource.start_day "30-Mar-2017"
|
335
|
+
new_resource.start_time "13:12"
|
333
336
|
end
|
334
337
|
|
335
338
|
context "when no attributes are modified" do
|
@@ -368,6 +371,116 @@ describe Chef::Provider::WindowsTask do
|
|
368
371
|
end
|
369
372
|
end
|
370
373
|
|
374
|
+
describe "#start_day_updated?" do
|
375
|
+
before do
|
376
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
377
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("MM/dd/yyyy")
|
378
|
+
provider.load_current_resource
|
379
|
+
|
380
|
+
new_resource.command "chef-client"
|
381
|
+
new_resource.run_level :highest
|
382
|
+
new_resource.frequency :minute
|
383
|
+
new_resource.frequency_modifier 15
|
384
|
+
new_resource.user "SYSTEM"
|
385
|
+
new_resource.execution_time_limit "PT72H"
|
386
|
+
new_resource.start_day "30-Mar-2017"
|
387
|
+
new_resource.start_time "13:12"
|
388
|
+
end
|
389
|
+
context "when start_day not changed" do
|
390
|
+
it "returns false" do
|
391
|
+
expect(provider.send(:start_day_updated?)).to be(false)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
context "when start_day changed" do
|
396
|
+
it "returns true" do
|
397
|
+
new_resource.start_day "01/01/2000"
|
398
|
+
expect(provider.send(:start_day_updated?)).to be(true)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
describe "#start_time_updated?" do
|
404
|
+
before do
|
405
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
406
|
+
provider.load_current_resource
|
407
|
+
|
408
|
+
new_resource.command "chef-client"
|
409
|
+
new_resource.run_level :highest
|
410
|
+
new_resource.frequency :minute
|
411
|
+
new_resource.frequency_modifier 15
|
412
|
+
new_resource.user "SYSTEM"
|
413
|
+
new_resource.execution_time_limit "PT72H"
|
414
|
+
new_resource.start_day "3/30/2017"
|
415
|
+
new_resource.start_time "13:12"
|
416
|
+
end
|
417
|
+
context "when start_time not changed" do
|
418
|
+
it "returns false" do
|
419
|
+
expect(provider.send(:start_time_updated?)).to be(false)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
context "when start_time changed" do
|
424
|
+
it "returns true" do
|
425
|
+
new_resource.start_time "01:01"
|
426
|
+
expect(provider.send(:start_time_updated?)).to be(true)
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
describe "#convert_user_date_to_system_date" do
|
432
|
+
it "when current resource start date is '30-May-2017' then returns '05/30/2017'" do
|
433
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("MM/dd/yyyy")
|
434
|
+
expect(provider.send(:convert_user_date_to_system_date, "30-May-2017")).to eq("05/30/2017")
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
describe "#convert_system_date_format_to_ruby_date_format" do
|
439
|
+
context "when system date format 'dd-MMM-yy'" do
|
440
|
+
it "returns '%d-%b-%y'" do
|
441
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("dd-MMM-yy")
|
442
|
+
expect(provider.send(:convert_system_date_format_to_ruby_date_format)).to eq("%d-%b-%y")
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
context "when system date format 'dd/MM/yyyy'" do
|
447
|
+
it "returns '%d/%m/%Y'" do
|
448
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("dd/MM/yyyy")
|
449
|
+
expect(provider.send(:convert_system_date_format_to_ruby_date_format)).to eq("%d/%m/%Y")
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
describe "#convert_system_date_format_to_ruby_long_date" do
|
455
|
+
context "when system date format 'dd-MMM-yy'" do
|
456
|
+
it "returns '%d-%m-%Y'" do
|
457
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("dd-MMM-yy")
|
458
|
+
expect(provider.send(:convert_system_date_format_to_ruby_long_date)).to eq("%d-%m-%Y")
|
459
|
+
end
|
460
|
+
end
|
461
|
+
|
462
|
+
context "when system date format 'dd/MM/yyyy'" do
|
463
|
+
it "returns '%d/%m/%Y'" do
|
464
|
+
allow(provider).to receive(:get_system_short_date_format).and_return("dd/MM/yyyy")
|
465
|
+
expect(provider.send(:convert_system_date_format_to_ruby_long_date)).to eq("%d/%m/%Y")
|
466
|
+
end
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
470
|
+
describe "#common_date_format_conversion" do
|
471
|
+
context "when system date format 'dd-MM-yyyy'" do
|
472
|
+
it "returns '%d-%m-%Y'" do
|
473
|
+
expect(provider.send(:common_date_format_conversion, "dd-MM-yyyy")).to eq("%d-%m-%Y")
|
474
|
+
end
|
475
|
+
end
|
476
|
+
|
477
|
+
context "when system date format 'd-M-yyyy'" do
|
478
|
+
it "returns '%d-%m-%Y'" do
|
479
|
+
expect(provider.send(:common_date_format_conversion, "dd-MM-yyyy")).to eq("%d-%m-%Y")
|
480
|
+
end
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
371
484
|
describe "#update_task_xml" do
|
372
485
|
before do
|
373
486
|
new_resource.command "chef-client"
|
@@ -63,7 +63,7 @@ EOH
|
|
63
63
|
let(:lcm_standard_error) { nil }
|
64
64
|
let(:lcm_cmdlet_success) { true }
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
|
67
67
|
test_configuration_result = lcm.test_configuration("config", {})
|
68
68
|
expect(test_configuration_result.class).to be(Array)
|
69
69
|
expect(test_configuration_result.length).to be > 0
|
@@ -71,6 +71,58 @@ EOH
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
context "when running on PowerShell version 5" do
|
75
|
+
let(:lcm_standard_output) { normal_lcm_output }
|
76
|
+
let(:lcm_standard_error) { nil }
|
77
|
+
let(:lcm_cmdlet_success) { true }
|
78
|
+
|
79
|
+
it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
|
80
|
+
allow(lcm).to receive(:ps_version_gte_5?).and_return(true)
|
81
|
+
test_configuration_result = lcm.test_configuration("config", {})
|
82
|
+
expect(test_configuration_result.class).to be(Array)
|
83
|
+
expect(test_configuration_result.length).to be > 0
|
84
|
+
expect(Chef::Log).not_to receive(:warn)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when running on PowerShell version less than 5" do
|
89
|
+
let(:lcm_standard_output) { normal_lcm_output }
|
90
|
+
let(:lcm_standard_error) { nil }
|
91
|
+
let(:lcm_cmdlet_success) { true }
|
92
|
+
|
93
|
+
it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
|
94
|
+
allow(lcm).to receive(:ps_version_gte_5?).and_return(false)
|
95
|
+
test_configuration_result = lcm.test_configuration("config", {})
|
96
|
+
expect(test_configuration_result.class).to be(Array)
|
97
|
+
expect(test_configuration_result.length).to be > 0
|
98
|
+
expect(Chef::Log).not_to receive(:warn)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "#lcm_command" do
|
103
|
+
let(:common_command_prefix) { "$ProgressPreference = 'SilentlyContinue';" }
|
104
|
+
let(:ps4_base_command) { "#{common_command_prefix} Start-DscConfiguration -path tmp -wait -erroraction 'stop' -force" }
|
105
|
+
let(:lcm_command_ps4) { ps4_base_command + " -whatif; if (! $?) { exit 1 }" }
|
106
|
+
let(:lcm_command_ps5) { "#{common_command_prefix} Test-DscConfiguration -path tmp" }
|
107
|
+
let(:lcm_standard_output) { normal_lcm_output }
|
108
|
+
let(:lcm_standard_error) { nil }
|
109
|
+
let(:lcm_cmdlet_success) { true }
|
110
|
+
|
111
|
+
it "successfully returns command when apply_configuration true" do
|
112
|
+
expect(lcm.send(:lcm_command, true)).to eq(ps4_base_command)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "successfully returns command when PowerShell version 4" do
|
116
|
+
allow(lcm).to receive(:ps_version_gte_5?).and_return(false)
|
117
|
+
expect(lcm.send(:lcm_command, false)).to eq(lcm_command_ps4)
|
118
|
+
end
|
119
|
+
|
120
|
+
it "successfully returns command when PowerShell version 5" do
|
121
|
+
allow(lcm).to receive(:ps_version_gte_5?).and_return(true)
|
122
|
+
expect(lcm.send(:lcm_command, false)).to eq(lcm_command_ps5)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
74
126
|
context "that fails due to missing what-if switch in DSC resource cmdlet implementation" do
|
75
127
|
let(:lcm_standard_output) { "" }
|
76
128
|
let(:lcm_standard_error) { no_whatif_lcm_output }
|
@@ -80,7 +132,7 @@ EOH
|
|
80
132
|
expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy
|
81
133
|
end
|
82
134
|
|
83
|
-
it "
|
135
|
+
it "returns a (possibly empty) array of ResourceInfo instances" do
|
84
136
|
expect(Chef::Log).to receive(:warn).at_least(:once)
|
85
137
|
expect(lcm).to receive(:whatif_not_supported?).and_call_original
|
86
138
|
test_configuration_result = nil
|
@@ -94,14 +146,14 @@ EOH
|
|
94
146
|
let(:lcm_standard_error) { dsc_resource_import_failure_output }
|
95
147
|
let(:lcm_cmdlet_success) { false }
|
96
148
|
|
97
|
-
it "
|
149
|
+
it "logs a warning if the message is formatted as expected when a resource import failure occurs" do
|
98
150
|
expect(Chef::Log).to receive(:warn).at_least(:once)
|
99
151
|
expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
|
100
152
|
test_configuration_result = nil
|
101
153
|
expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
|
102
154
|
end
|
103
155
|
|
104
|
-
it "
|
156
|
+
it "returns a (possibly empty) array of ResourceInfo instances" do
|
105
157
|
expect(Chef::Log).to receive(:warn).at_least(:once)
|
106
158
|
test_configuration_result = nil
|
107
159
|
expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
|
@@ -114,7 +166,7 @@ EOH
|
|
114
166
|
let(:lcm_standard_error) { "Abort, Retry, Fail?" }
|
115
167
|
let(:lcm_cmdlet_success) { false }
|
116
168
|
|
117
|
-
it "
|
169
|
+
it "logs a warning" do
|
118
170
|
expect(Chef::Log).to receive(:warn).at_least(:once)
|
119
171
|
expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
|
120
172
|
expect { lcm.test_configuration("config", {}) }.not_to raise_error
|
@@ -122,15 +174,15 @@ EOH
|
|
122
174
|
end
|
123
175
|
end
|
124
176
|
|
125
|
-
it "
|
177
|
+
it "identify a correctly formatted error message as a resource import failure" do
|
126
178
|
expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output)).to be(true)
|
127
179
|
end
|
128
180
|
|
129
|
-
it "
|
181
|
+
it "does not identify an incorrectly formatted error message as a resource import failure" do
|
130
182
|
expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("module", "gibberish"))).to be(false)
|
131
183
|
end
|
132
184
|
|
133
|
-
it "
|
185
|
+
it "does not identify a message without a CimException reference as a resource import failure" do
|
134
186
|
expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("CimException", "ArgumentException"))).to be(false)
|
135
187
|
end
|
136
188
|
end
|
data/tasks/.DS_Store
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.4.
|
4
|
+
version: 13.4.24
|
5
5
|
platform: universal-mingw32
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 13.4.
|
19
|
+
version: 13.4.24
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 13.4.
|
26
|
+
version: 13.4.24
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mixlib-cli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -624,6 +624,7 @@ files:
|
|
624
624
|
- README.md
|
625
625
|
- Rakefile
|
626
626
|
- VERSION
|
627
|
+
- acceptance/.DS_Store
|
627
628
|
- acceptance/.gitignore
|
628
629
|
- acceptance/.shared/kitchen_acceptance/.kitchen.digitalocean.yml
|
629
630
|
- acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml
|
@@ -709,6 +710,7 @@ files:
|
|
709
710
|
- bin/knife
|
710
711
|
- chef-universal-mingw32.gemspec
|
711
712
|
- chef.gemspec
|
713
|
+
- distro/.DS_Store
|
712
714
|
- distro/common/html/_sources/ctl_chef_client.txt
|
713
715
|
- distro/common/html/_sources/ctl_chef_server.txt
|
714
716
|
- distro/common/html/_sources/ctl_chef_shell.txt
|
@@ -2783,6 +2785,7 @@ files:
|
|
2783
2785
|
- spec/unit/win32/registry_spec.rb
|
2784
2786
|
- spec/unit/win32/security_spec.rb
|
2785
2787
|
- spec/unit/windows_service_spec.rb
|
2788
|
+
- tasks/.DS_Store
|
2786
2789
|
- tasks/announce.rb
|
2787
2790
|
- tasks/bin/run_external_test
|
2788
2791
|
- tasks/cbgb.rb
|