Merge pull request #6800 from mitchellh/gildegoma/ansible-bug-fixes

provisioners/ansible_local: bug fixes

Resolve #6740, #6757, and #6793
This commit is contained in:
Gilles Cornu 2016-01-14 00:27:56 +01:00
commit d518f712db
5 changed files with 18 additions and 12 deletions

View File

@ -2,8 +2,10 @@
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]
- provisioners/ansible_local: Change the way to verify `ansible-galaxy`
presence, to avoid a non-zero status code with Ansible 2.0 [GH-6793]
## 1.8.1 (December 21, 2015)

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ module VagrantPlugins
# Check that ansible binaries are well installed on the guest,
@machine.communicate.execute(
"ansible-galaxy --help && ansible-playbook --help",
"ansible-galaxy info --help && ansible-playbook --help",
:error_class => Ansible::Errors::AnsibleNotFoundOnGuest,
:error_key => :ansible_not_found_on_guest)