Merge pull request #3593 from mitchellh/elevated-winrm-shell-provisioner
provisioner/shell: Elevated winrm shell provisioner
This commit is contained in:
commit
97e2af2374
|
@ -96,12 +96,10 @@ module VagrantPlugins
|
||||||
exec_path.gsub!('/', '\\')
|
exec_path.gsub!('/', '\\')
|
||||||
exec_path = "c:#{exec_path}" if exec_path.start_with?("\\")
|
exec_path = "c:#{exec_path}" if exec_path.start_with?("\\")
|
||||||
|
|
||||||
command = <<-EOH
|
# For PowerShell scripts bypass the execution policy
|
||||||
$old = Get-ExecutionPolicy;
|
command = "#{exec_path}#{args}"
|
||||||
Set-ExecutionPolicy Unrestricted -force;
|
command = "powershell -executionpolicy bypass -file #{command}" if
|
||||||
#{exec_path}#{args};
|
File.extname(exec_path).downcase == '.ps1'
|
||||||
Set-ExecutionPolicy $old -force
|
|
||||||
EOH
|
|
||||||
|
|
||||||
if config.path
|
if config.path
|
||||||
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
|
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
|
||||||
|
@ -112,7 +110,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
# Execute it with sudo
|
# Execute it with sudo
|
||||||
comm.sudo(command) do |type, data|
|
comm.sudo(command, elevated: config.privileged) do |type, data|
|
||||||
handle_comm(type, data)
|
handle_comm(type, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -143,8 +141,6 @@ module VagrantPlugins
|
||||||
ensure
|
ensure
|
||||||
download_path.delete if download_path.file?
|
download_path.delete if download_path.file?
|
||||||
end
|
end
|
||||||
|
|
||||||
download_path.delete
|
|
||||||
elsif config.path
|
elsif config.path
|
||||||
# Just yield the path to that file...
|
# Just yield the path to that file...
|
||||||
root_path = @machine.env.root_path
|
root_path = @machine.env.root_path
|
||||||
|
|
Loading…
Reference in New Issue