diff --git a/CHANGELOG.md b/CHANGELOG.md index f4dc1eaf1..f8729dc8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ BUG FIXES: - - provisioners/ansible_local: Fix error in `playbook` existence check when - running on a Windows host [GH-6740] + - provisioners/ansible_local: Fix errors in absolute paths to playbook or + galaxy resources when running on a Windows host [GH-6740, GH-6757] ## 1.8.1 (December 21, 2015) diff --git a/plugins/provisioners/ansible/config/guest.rb b/plugins/provisioners/ansible/config/guest.rb index bfd9444ce..1845870ca 100644 --- a/plugins/provisioners/ansible/config/guest.rb +++ b/plugins/provisioners/ansible/config/guest.rb @@ -37,10 +37,7 @@ module VagrantPlugins protected def check_path(machine, path, test_args, error_message_key = nil) - remote_path = File.expand_path(path, @provisioning_path) - - # Remove drive letter if running on a Windows host - remote_path = remote_path.gsub(/^[a-zA-Z]:/, "") + remote_path = Helpers::expand_path_in_unix_style(path, @provisioning_path) if machine.communicate.ready? && !machine.communicate.test("test #{test_args} #{remote_path}") if error_message_key diff --git a/plugins/provisioners/ansible/helpers.rb b/plugins/provisioners/ansible/helpers.rb index 1bdb57366..9795ab923 100644 --- a/plugins/provisioners/ansible/helpers.rb +++ b/plugins/provisioners/ansible/helpers.rb @@ -25,6 +25,12 @@ module VagrantPlugins 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 diff --git a/plugins/provisioners/ansible/provisioner/base.rb b/plugins/provisioners/ansible/provisioner/base.rb index 291df8213..813f96a3e 100644 --- a/plugins/provisioners/ansible/provisioner/base.rb +++ b/plugins/provisioners/ansible/provisioner/base.rb @@ -179,15 +179,16 @@ module VagrantPlugins end end - def get_galaxy_role_file(basedir) - File.expand_path(config.galaxy_role_file, basedir) + def get_galaxy_role_file(base_dir) + Helpers::expand_path_in_unix_style(config.galaxy_role_file, base_dir) end - def get_galaxy_roles_path(basedir) + def get_galaxy_roles_path(base_dir) if config.galaxy_roles_path - File.expand_path(config.galaxy_roles_path, basedir) + Helpers::expand_path_in_unix_style(config.galaxy_roles_path, base_dir) else - File.join(Pathname.new(config.playbook).expand_path(basedir).parent, 'roles') + playbook_path = Helpers::expand_path_in_unix_style(config.playbook, base_dir) + File.join(Pathname.new(playbook_path).parent, 'roles') end end