ansible_local: Add `pip_args` option
With this new option, it is now possible to pass additional arguments to pip command when the `install_mode` is "pip". (@gildegoma reworded the original commit message of pull request GH-8170)
This commit is contained in:
parent
f807e5a8be
commit
7e2e5654ed
|
@ -7,7 +7,7 @@ module VagrantPlugins
|
|||
module Arch
|
||||
module AnsibleInstall
|
||||
|
||||
def self.ansible_install(machine, install_mode, ansible_version)
|
||||
def self.ansible_install(machine, install_mode, ansible_version, pip_args)
|
||||
if install_mode == :pip
|
||||
raise Ansible::Errors::AnsiblePipInstallIsNotSupported
|
||||
else
|
||||
|
|
|
@ -8,17 +8,17 @@ module VagrantPlugins
|
|||
module AnsibleInstall
|
||||
|
||||
|
||||
def self.ansible_install(machine, install_mode, ansible_version)
|
||||
def self.ansible_install(machine, install_mode, ansible_version, pip_args)
|
||||
if (install_mode == :pip)
|
||||
ansible_pip_install machine, ansible_version
|
||||
ansible_pip_install machine, ansible_version, pip_args
|
||||
else
|
||||
ansible_apt_install machine
|
||||
end
|
||||
end
|
||||
|
||||
def self.ansible_pip_install(machine, ansible_version)
|
||||
def self.ansible_pip_install(machine, ansible_version, pip_args)
|
||||
pip_setup machine
|
||||
Pip::pip_install machine, "ansible", ansible_version
|
||||
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,12 +8,12 @@ module VagrantPlugins
|
|||
module Fedora
|
||||
module AnsibleInstall
|
||||
|
||||
def self.ansible_install(machine, install_mode, ansible_version)
|
||||
def self.ansible_install(machine, install_mode, ansible_version, pip_args)
|
||||
rpm_package_manager = Facts::rpm_package_manager(machine)
|
||||
|
||||
if install_mode == :pip
|
||||
pip_setup machine
|
||||
Pip::pip_install machine, "ansible", ansible_version
|
||||
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||
else
|
||||
machine.communicate.sudo "#{rpm_package_manager} -y install ansible"
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
|||
module Guest
|
||||
module Pip
|
||||
|
||||
def self.pip_install(machine, package, version = "", upgrade = true)
|
||||
def self.pip_install(machine, package, version = "", pip_args = "", upgrade = true)
|
||||
upgrade_arg = "--upgrade " if upgrade
|
||||
version_arg = ""
|
||||
|
||||
|
@ -13,7 +13,7 @@ module VagrantPlugins
|
|||
version_arg = "==#{version}"
|
||||
end
|
||||
|
||||
machine.communicate.sudo "pip install #{upgrade_arg}#{package}#{version_arg}"
|
||||
machine.communicate.sudo "pip install #{pip_args} #{upgrade_arg}#{package}#{version_arg}"
|
||||
end
|
||||
|
||||
def self.get_pip(machine)
|
||||
|
|
|
@ -8,10 +8,10 @@ module VagrantPlugins
|
|||
module RedHat
|
||||
module AnsibleInstall
|
||||
|
||||
def self.ansible_install(machine, install_mode, ansible_version)
|
||||
def self.ansible_install(machine, install_mode, ansible_version, pip_args)
|
||||
if install_mode == :pip
|
||||
pip_setup machine
|
||||
Pip::pip_install machine, "ansible", ansible_version
|
||||
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||
else
|
||||
ansible_rpm_install machine
|
||||
end
|
||||
|
|
|
@ -7,9 +7,9 @@ module VagrantPlugins
|
|||
module Ubuntu
|
||||
module AnsibleInstall
|
||||
|
||||
def self.ansible_install(machine, install_mode, ansible_version)
|
||||
def self.ansible_install(machine, install_mode, ansible_version, pip_args)
|
||||
if install_mode == :pip
|
||||
Debian::AnsibleInstall::ansible_pip_install machine, ansible_version
|
||||
Debian::AnsibleInstall::ansible_pip_install machine, ansible_version, pip_args
|
||||
else
|
||||
ansible_apt_install machine
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ module VagrantPlugins
|
|||
attr_accessor :tmp_path
|
||||
attr_accessor :install
|
||||
attr_accessor :install_mode
|
||||
attr_accessor :pip_args
|
||||
attr_accessor :version
|
||||
|
||||
def initialize
|
||||
|
@ -17,6 +18,7 @@ module VagrantPlugins
|
|||
|
||||
@install = UNSET_VALUE
|
||||
@install_mode = UNSET_VALUE
|
||||
@pip_args = UNSET_VALUE
|
||||
@provisioning_path = UNSET_VALUE
|
||||
@tmp_path = UNSET_VALUE
|
||||
@version = UNSET_VALUE
|
||||
|
@ -27,6 +29,7 @@ module VagrantPlugins
|
|||
|
||||
@install = true if @install == UNSET_VALUE
|
||||
@install_mode = :default if @install_mode == UNSET_VALUE
|
||||
@pip_args = "" if @pip_args == UNSET_VALUE
|
||||
@provisioning_path = "/vagrant" if provisioning_path == UNSET_VALUE
|
||||
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
|
||||
@version = "" if @version == UNSET_VALUE
|
||||
|
|
|
@ -49,7 +49,7 @@ module VagrantPlugins
|
|||
(config.version.to_s.to_sym == :latest ||
|
||||
!@machine.guest.capability(:ansible_installed, config.version))
|
||||
@machine.ui.detail I18n.t("vagrant.provisioners.ansible.installing")
|
||||
@machine.guest.capability(:ansible_install, config.install_mode, config.version)
|
||||
@machine.guest.capability(:ansible_install, config.install_mode, config.version, config.pip_args)
|
||||
end
|
||||
|
||||
# Check that Ansible Playbook command is available on the guest
|
||||
|
|
|
@ -27,6 +27,7 @@ describe VagrantPlugins::Ansible::Config::Guest do
|
|||
install_mode
|
||||
inventory_path
|
||||
limit
|
||||
pip_args
|
||||
playbook
|
||||
playbook_command
|
||||
provisioning_path
|
||||
|
|
|
@ -79,6 +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)).
|
||||
|
||||
- `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.
|
||||
|
||||
The default value is `/vagrant`.
|
||||
|
|
Loading…
Reference in New Issue