Update shell provisioner for powershell to add "shell_args", saner defaults and more useful detail in logging output; Add Eclipse .project file to .gitignore IDE section

This commit is contained in:
Eris Belew 2014-09-23 12:46:25 -07:00
parent 6747f12951
commit 7a73f5bd7c
4 changed files with 17 additions and 4 deletions

1
.gitignore vendored
View File

@ -31,6 +31,7 @@ doc/
# IDE junk # IDE junk
.idea/* .idea/*
*.iml *.iml
.project
# Ruby Managers # Ruby Managers
.rbenv .rbenv

View File

@ -10,6 +10,7 @@ module VagrantPlugins
attr_accessor :privileged attr_accessor :privileged
attr_accessor :binary attr_accessor :binary
attr_accessor :keep_color attr_accessor :keep_color
attr_accessor :shell_args
def initialize def initialize
@args = UNSET_VALUE @args = UNSET_VALUE
@ -19,6 +20,7 @@ module VagrantPlugins
@privileged = UNSET_VALUE @privileged = UNSET_VALUE
@binary = UNSET_VALUE @binary = UNSET_VALUE
@keep_color = UNSET_VALUE @keep_color = UNSET_VALUE
@shell_args = UNSET_VALUE
end end
def finalize! def finalize!
@ -29,6 +31,7 @@ module VagrantPlugins
@privileged = true if @privileged == UNSET_VALUE @privileged = true if @privileged == UNSET_VALUE
@binary = false if @binary == UNSET_VALUE @binary = false if @binary == UNSET_VALUE
@keep_color = false if @keep_color == UNSET_VALUE @keep_color = false if @keep_color == UNSET_VALUE
@shell_args = "-ExecutionPolicy Bypass" if @shell_args == UNSET_VALUE
if @args && args_valid? if @args && args_valid?
@args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s @args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s

View File

@ -100,14 +100,22 @@ 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?("\\")
# For PowerShell scripts bypass the execution policy # Copy shell_args from configuration
shell_args = config.shell_args
# For PowerShell scripts bypass the execution policy unless already specified
shell_args += " -ExecutionPolicy Bypass" if config.shell_args !~ /[-\/]ExecutionPolicy/i
# CLIXML output is kinda useless, especially on non-windows hosts
shell_args += " -OutputFormat Text" if config.shell_args !~ /[-\/]OutputFormat/i
command = "#{exec_path}#{args}" command = "#{exec_path}#{args}"
command = "powershell -executionpolicy bypass -file #{command}" if command = "powershell #{shell_args.to_s} -file #{command}" if
File.extname(exec_path).downcase == '.ps1' File.extname(exec_path).downcase == '.ps1'
if config.path if config.path
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", @machine.ui.detail(I18n.t("vagrant.provisioners.shell.runningas",
script: exec_path)) local: config.path.to_s, remote: exec_path))
else else
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
script: "inline PowerShell script")) script: "inline PowerShell script"))

View File

@ -1773,6 +1773,7 @@ en:
path_and_inline_set: "Only one of `path` or `inline` may be set." path_and_inline_set: "Only one of `path` or `inline` may be set."
path_invalid: "`path` for shell provisioner does not exist on the host system: %{path}" path_invalid: "`path` for shell provisioner does not exist on the host system: %{path}"
running: "Running: %{script}" running: "Running: %{script}"
runningas: "Running: %{local} as %{remote}"
upload_path_not_set: "`upload_path` must be set for the shell provisioner." upload_path_not_set: "`upload_path` must be set for the shell provisioner."
ansible: ansible: