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 Arch
|
||||||
module AnsibleInstall
|
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
|
if install_mode == :pip
|
||||||
raise Ansible::Errors::AnsiblePipInstallIsNotSupported
|
raise Ansible::Errors::AnsiblePipInstallIsNotSupported
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,17 +8,17 @@ module VagrantPlugins
|
||||||
module AnsibleInstall
|
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)
|
if (install_mode == :pip)
|
||||||
ansible_pip_install machine, ansible_version
|
ansible_pip_install machine, ansible_version, pip_args
|
||||||
else
|
else
|
||||||
ansible_apt_install machine
|
ansible_apt_install machine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ansible_pip_install(machine, ansible_version)
|
def self.ansible_pip_install(machine, ansible_version, pip_args)
|
||||||
pip_setup machine
|
pip_setup machine
|
||||||
Pip::pip_install machine, "ansible", ansible_version
|
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -8,12 +8,12 @@ module VagrantPlugins
|
||||||
module Fedora
|
module Fedora
|
||||||
module AnsibleInstall
|
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)
|
rpm_package_manager = Facts::rpm_package_manager(machine)
|
||||||
|
|
||||||
if install_mode == :pip
|
if install_mode == :pip
|
||||||
pip_setup machine
|
pip_setup machine
|
||||||
Pip::pip_install machine, "ansible", ansible_version
|
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||||
else
|
else
|
||||||
machine.communicate.sudo "#{rpm_package_manager} -y install ansible"
|
machine.communicate.sudo "#{rpm_package_manager} -y install ansible"
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module VagrantPlugins
|
||||||
module Guest
|
module Guest
|
||||||
module Pip
|
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
|
upgrade_arg = "--upgrade " if upgrade
|
||||||
version_arg = ""
|
version_arg = ""
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ module VagrantPlugins
|
||||||
version_arg = "==#{version}"
|
version_arg = "==#{version}"
|
||||||
end
|
end
|
||||||
|
|
||||||
machine.communicate.sudo "pip install #{upgrade_arg}#{package}#{version_arg}"
|
machine.communicate.sudo "pip install #{pip_args} #{upgrade_arg}#{package}#{version_arg}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_pip(machine)
|
def self.get_pip(machine)
|
||||||
|
|
|
@ -8,10 +8,10 @@ module VagrantPlugins
|
||||||
module RedHat
|
module RedHat
|
||||||
module AnsibleInstall
|
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
|
if install_mode == :pip
|
||||||
pip_setup machine
|
pip_setup machine
|
||||||
Pip::pip_install machine, "ansible", ansible_version
|
Pip::pip_install machine, "ansible", ansible_version, pip_args
|
||||||
else
|
else
|
||||||
ansible_rpm_install machine
|
ansible_rpm_install machine
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,9 +7,9 @@ module VagrantPlugins
|
||||||
module Ubuntu
|
module Ubuntu
|
||||||
module AnsibleInstall
|
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
|
if install_mode == :pip
|
||||||
Debian::AnsibleInstall::ansible_pip_install machine, ansible_version
|
Debian::AnsibleInstall::ansible_pip_install machine, ansible_version, pip_args
|
||||||
else
|
else
|
||||||
ansible_apt_install machine
|
ansible_apt_install machine
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,7 @@ module VagrantPlugins
|
||||||
attr_accessor :tmp_path
|
attr_accessor :tmp_path
|
||||||
attr_accessor :install
|
attr_accessor :install
|
||||||
attr_accessor :install_mode
|
attr_accessor :install_mode
|
||||||
|
attr_accessor :pip_args
|
||||||
attr_accessor :version
|
attr_accessor :version
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -17,6 +18,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
@install = UNSET_VALUE
|
@install = UNSET_VALUE
|
||||||
@install_mode = UNSET_VALUE
|
@install_mode = UNSET_VALUE
|
||||||
|
@pip_args = UNSET_VALUE
|
||||||
@provisioning_path = UNSET_VALUE
|
@provisioning_path = UNSET_VALUE
|
||||||
@tmp_path = UNSET_VALUE
|
@tmp_path = UNSET_VALUE
|
||||||
@version = UNSET_VALUE
|
@version = UNSET_VALUE
|
||||||
|
@ -27,6 +29,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
@install = true if @install == UNSET_VALUE
|
@install = true if @install == UNSET_VALUE
|
||||||
@install_mode = :default if @install_mode == 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
|
@provisioning_path = "/vagrant" if provisioning_path == UNSET_VALUE
|
||||||
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
|
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
|
||||||
@version = "" if @version == UNSET_VALUE
|
@version = "" if @version == UNSET_VALUE
|
||||||
|
|
|
@ -49,7 +49,7 @@ module VagrantPlugins
|
||||||
(config.version.to_s.to_sym == :latest ||
|
(config.version.to_s.to_sym == :latest ||
|
||||||
!@machine.guest.capability(:ansible_installed, config.version))
|
!@machine.guest.capability(:ansible_installed, config.version))
|
||||||
@machine.ui.detail I18n.t("vagrant.provisioners.ansible.installing")
|
@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
|
end
|
||||||
|
|
||||||
# Check that Ansible Playbook command is available on the guest
|
# Check that Ansible Playbook command is available on the guest
|
||||||
|
|
|
@ -27,6 +27,7 @@ describe VagrantPlugins::Ansible::Config::Guest do
|
||||||
install_mode
|
install_mode
|
||||||
inventory_path
|
inventory_path
|
||||||
limit
|
limit
|
||||||
|
pip_args
|
||||||
playbook
|
playbook
|
||||||
playbook_command
|
playbook_command
|
||||||
provisioning_path
|
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.
|
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.
|
- `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`.
|
The default value is `/vagrant`.
|
||||||
|
|
Loading…
Reference in New Issue