forked from oneops/kitchenci-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-kitchen-v1.16.0_1.patch
86 lines (77 loc) · 2.79 KB
/
test-kitchen-v1.16.0_1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
*** /home/phuynh/.gem/ruby/2.0.0/gems/test-kitchen-1.16.0/lib/kitchen/provisioner/chef_solo.rb 2017-07-07 07:30:19.413190068 -0700
--- lib/kitchen/provisioner/chef_solo.rb 2017-07-06 13:16:45.422204134 -0700
***************
*** 45,50 ****
--- 45,51 ----
def create_sandbox
super
prepare_config_rb
+ prepare_script
end
def modern?
***************
*** 64,78 ****
# (see Base#run_command)
def run_command
config[:log_level] = "info" if !modern? && config[:log_level] = "auto"
cmd = sudo(config[:chef_solo_path]).dup
.tap { |str| str.insert(0, "& ") if powershell_shell? }
! chef_cmd(cmd)
end
private
# Returns an Array of command line arguments for the chef client.
#
# @return [Array<String>] an array of command line arguments
--- 65,120 ----
# (see Base#run_command)
def run_command
+ ## begin of bootstrap
+ # added shell provision to run before converge
+ script = remote_path_join(
+ config[:root_path], File.basename(config[:script])
+ )
+
+ code = powershell_shell? ? %{& "#{script}"} : sudo(script)
+ ## end of bootstrap
+
config[:log_level] = "info" if !modern? && config[:log_level] = "auto"
cmd = sudo(config[:chef_solo_path]).dup
.tap { |str| str.insert(0, "& ") if powershell_shell? }
! chef_cmd("#{code} ; #{cmd}")
end
private
+
+ def prepare_script
+ info("Preparing script")
+
+ if config[:script]
+ debug("Using script from #{config[:script]}")
+ FileUtils.cp_r(config[:script], sandbox_path)
+ else
+ prepare_stubbed_script
+ end
+
+ FileUtils.chmod(0755,
+ File.join(sandbox_path, File.basename(config[:script])))
+ end
+
+ # Create a minimal, no-op script in the sandbox path.
+ #
+ # @api private
+ def prepare_stubbed_script
+ base = powershell_shell? ? "bootstrap.ps1" : "bootstrap.sh"
+ config[:script] = File.join(sandbox_path, base)
+ info("#{File.basename(config[:script])} not found " \
+ "so Kitchen will run a stubbed script. Is this intended?")
+ File.open(config[:script], "wb") do |file|
+ if powershell_shell?
+ file.write(%{Write-Host "NO BOOTSTRAP SCRIPT PRESENT`n"\n})
+ else
+ file.write(%{#!/bin/sh\necho "NO BOOTSTRAP SCRIPT PRESENT"\n})
+ end
+ end
+ end
+
# Returns an Array of command line arguments for the chef client.
#
# @return [Array<String>] an array of command line arguments