ansible_local: Polish the new `pip_args` option

Ref GH-8170
This commit is contained in:
Gilles Cornu 2017-03-23 08:16:45 +01:00
parent 7e2e5654ed
commit b40d347944
No known key found for this signature in database
GPG Key ID: F6BC2CF7E1FE8FFF
2 changed files with 7 additions and 4 deletions

View File

@ -6,14 +6,16 @@ module VagrantPlugins
module Pip
def self.pip_install(machine, package, version = "", pip_args = "", upgrade = true)
upgrade_arg = "--upgrade " if upgrade
upgrade_arg = "--upgrade" if upgrade
version_arg = ""
if !version.to_s.empty? && version.to_s.to_sym != :latest
version_arg = "==#{version}"
end
machine.communicate.sudo "pip install #{pip_args} #{upgrade_arg}#{package}#{version_arg}"
args_array = [pip_args, upgrade_arg, "#{package}#{version_arg}"]
machine.communicate.sudo "pip install #{args_array.join(' ')}"
end
def self.get_pip(machine)

View File

@ -79,8 +79,9 @@ This section lists the _specific_ options for the Ansible Local provisioner. In
The default value is `:default`, and any invalid value for this option will silently fall back to the default value.
- `pip_args` (string) - When Ansible is installed via pip this option allows the defition of additional pip arguments to be passed along on the
command line (for example, [--index-url](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-i)).
- `pip_args` (string) - When Ansible is installed via pip, this option allows the definition of additional pip arguments to be passed along on the command line (for example, [`--index-url`](https://pip.pypa.io/en/stable/reference/pip_install/#cmdoption-i)).
By default, this option is not set.
- `provisioning_path` (string) - An absolute path on the guest machine where the Ansible files are stored. The `ansible-galaxy` and `ansible-playbook` commands are executed from this directory. This is the location to place an [ansible.cfg](http://docs.ansible.com/ansible/intro_configuration.html) file, in case you need it.