Fix #8328: Use special quote and backslash formatting for Windows when setting Salt pillar.
This commit is contained in:
parent
89a21f0f47
commit
5c50c50d73
|
@ -176,7 +176,19 @@ module VagrantPlugins
|
||||||
## Actions
|
## Actions
|
||||||
# Get pillar string to pass with the salt command
|
# Get pillar string to pass with the salt command
|
||||||
def get_pillar
|
def get_pillar
|
||||||
" pillar='#{@config.pillar_data.to_json}'" if !@config.pillar_data.empty?
|
if !@config.pillar_data.empty?
|
||||||
|
if @machine.config.vm.communicator == :winrm
|
||||||
|
# ' doesn't have any special behavior on the command prompt,
|
||||||
|
# so '{"x":"y"}' becomes '{x:y}' with literal single quotes.
|
||||||
|
# However, """ will become " , and \\""" will become \" .
|
||||||
|
# Use \\"" instead of \\""" for literal inner-value quotes
|
||||||
|
# to avoid issue with odd number of quotes.
|
||||||
|
# --% disables special PowerShell parsing on the rest of the line.
|
||||||
|
" --% pillar=#{@config.pillar_data.to_json.gsub(/(?<!\\)\"/, '"""').gsub(/\\\"/, %q(\\\\\""))}"
|
||||||
|
else
|
||||||
|
" pillar='#{@config.pillar_data.to_json}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get colorization option string to pass with the salt command
|
# Get colorization option string to pass with the salt command
|
||||||
|
|
Loading…
Reference in New Issue