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
|
# File 'lib/vagrant-windows/monkey_patches/chef_solo.rb', line 15
def run_chef_solo_on_windows
command_env = @config.binary_env ? "#{@config.binary_env} " : ""
command_args = @config.arguments ? " #{@config.arguments}" : ""
command_solo = "#{command_env}#{chef_binary_path("chef-solo")} "
command_solo << "-c #{@config.provisioning_path}/solo.rb "
command_solo << "-j #{@config.provisioning_path}/dna.json "
command_solo << "#{command_args}"
command = VagrantWindows.load_script_template("ps_runas.ps1",
:options => {
:user => machine.config.winrm.username,
:password => @machine.config.winrm.password,
:cmd => "powershell.exe",
:arguments => "-Command #{command_solo}"})
@config.attempts.times do |attempt|
if attempt == 0
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
else
@machine.env.ui.info I18n.t("vagrant.provisioners.chef.running_solo_again")
end
exit_status = @machine.communicate.sudo(command, :error_check => false) do |type, data|
color = type == :stdout ? :green : :red
@machine.env.ui.info(data.chomp, :color => color, :prefix => false)
end
return if exit_status == 0
end
raise ChefError, :no_convergence
end
|