Fix #8328: Use special quote and backslash formatting for Windows when setting Salt pillar.

This commit is contained in:
mtkennerly 2017-03-04 19:49:28 -05:00 committed by Brian Cain
parent 89a21f0f47
commit 5c50c50d73
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
1 changed files with 13 additions and 1 deletions

View File

@ -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