Merge pull request #5607 from purpleidea/feat/named-shell

Add :name attribute to shell provisioner.
This commit is contained in:
Seth Vargo 2015-05-30 20:54:34 -07:00
commit afc02ed681
3 changed files with 17 additions and 2 deletions

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 :name
attr_accessor :powershell_args attr_accessor :powershell_args
def initialize def initialize
@ -20,6 +21,7 @@ module VagrantPlugins
@privileged = UNSET_VALUE @privileged = UNSET_VALUE
@binary = UNSET_VALUE @binary = UNSET_VALUE
@keep_color = UNSET_VALUE @keep_color = UNSET_VALUE
@name = UNSET_VALUE
@powershell_args = UNSET_VALUE @powershell_args = UNSET_VALUE
end end
@ -31,11 +33,15 @@ 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
@name = nil if @name == UNSET_VALUE
@powershell_args = "-ExecutionPolicy Bypass" if @powershell_args == UNSET_VALUE @powershell_args = "-ExecutionPolicy Bypass" if @powershell_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
end end
if not(@name.nil?) and not(@name.is_a?(String))
@name = nil
end
end end
def validate(machine) def validate(machine)

View File

@ -65,7 +65,10 @@ module VagrantPlugins
comm.upload(path.to_s, config.upload_path) comm.upload(path.to_s, config.upload_path)
if config.path if not(config.name.nil?)
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
script: "Name: #{config.name}"))
elsif config.path
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
script: path.to_s)) script: path.to_s))
else else
@ -122,7 +125,10 @@ module VagrantPlugins
command = "powershell #{shell_args.to_s} -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 not(config.name.nil?)
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
script: "Name: #{config.name}"))
elsif config.path
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.runningas", @machine.ui.detail(I18n.t("vagrant.provisioners.shell.runningas",
local: config.path.to_s, remote: exec_path)) local: config.path.to_s, remote: exec_path))
else else

View File

@ -59,6 +59,9 @@ The remainder of the available options are optional:
true, Vagrant will not do this, allowing the native colors from the script true, Vagrant will not do this, allowing the native colors from the script
to be outputted. to be outputted.
* `name` (string) - This value will be displayed in the output so that
identification by the user is easier when many shell provisioners are present.
* `powershell_args` (string) - Extra arguments to pass to `PowerShell` * `powershell_args` (string) - Extra arguments to pass to `PowerShell`
if you're provisioning with PowerShell on Windows. if you're provisioning with PowerShell on Windows.