Gilles Cornu 1e38be237e provisioners/ansible: fix galaxy paths on Windows
Close #6757 and update previous fix for #6740 (#6741).

See also these places where the same regexp is used to address similar
"Windows cases":

 - ec85548bd6/plugins/provisioners/chef/provisioner/chef_solo.rb (L99-L103)
 - ec85548bd6/plugins/guests/windows/cap/rsync.rb (L6-L9)
2016-01-05 08:22:10 +01:00

43 lines
1.0 KiB
Ruby

require "vagrant"
module VagrantPlugins
module Ansible
class Helpers
def self.stringify_ansible_playbook_command(env, command)
shell_command = ''
env.each_pair do |k, v|
if k == 'ANSIBLE_SSH_ARGS'
shell_command += "#{k}='#{v}' "
else
shell_command += "#{k}=#{v} "
end
end
shell_arg = []
command.each do |arg|
if arg =~ /(--start-at-task|--limit)=(.+)/
shell_arg << "#{$1}='#{$2}'"
else
shell_arg << arg
end
end
shell_command += shell_arg.join(' ')
end
def self.expand_path_in_unix_style(path, base_dir)
# Remove the possible drive letter, which is added
# by `File.expand_path` when running on a Windows host
File.expand_path(path, base_dir).sub(/^[a-zA-Z]:/, "")
end
def self.as_list_argument(v)
v.kind_of?(Array) ? v.join(',') : v
end
def self.as_array(v)
v.kind_of?(Array) ? v : [v]
end
end
end
end