diff --git a/plugins/provisioners/ansible/cap/guest/pip/pip.rb b/plugins/provisioners/ansible/cap/guest/pip/pip.rb index 98a9ba0b8..307261a7f 100644 --- a/plugins/provisioners/ansible/cap/guest/pip/pip.rb +++ b/plugins/provisioners/ansible/cap/guest/pip/pip.rb @@ -5,6 +5,8 @@ module VagrantPlugins module Guest module Pip + DEFAULT_PIP_INSTALL_CMD = "curl https://bootstrap.pypa.io/get-pip.py | sudo python" + def self.pip_install(machine, package = "", version = "", pip_args = "", upgrade = true) upgrade_arg = "--upgrade" if upgrade version_arg = "" @@ -18,7 +20,17 @@ module VagrantPlugins machine.communicate.sudo "pip install #{args_array.join(' ')}" end - def self.get_pip(machine, pip_install_cmd="curl https://bootstrap.pypa.io/get-pip.py | sudo python") + def self.get_pip(machine, pip_install_cmd=DEFAULT_PIP_INSTALL_CMD) + + # The objective here is to get pip either by default + # or by the argument passed in. The objective is not + # to circumvent the pip setup by passing in nothing. + # Thus, we stick with the default on an empty string. + + if pip_install_cmd.empty? + pip_install_cmd=DEFAULT_PIP_INSTALL_CMD + end + machine.ui.detail I18n.t("vagrant.provisioners.ansible.installing_pip") machine.communicate.execute pip_install_cmd end diff --git a/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb b/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb index 79ecf7c1b..24f510186 100644 --- a/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb +++ b/test/unit/plugins/provisioners/ansible/cap/guest/pip/pip_test.rb @@ -36,6 +36,12 @@ describe VagrantPlugins::Ansible::Cap::Guest::Pip do expect(communicator).to receive(:execute).with(pip_install_command) subject.get_pip(machine,pip_install_command) end + + it "installs pip using the default command if the argument is empty" do + pip_install_command = "" + expect(communicator).to receive(:execute).with("curl https://bootstrap.pypa.io/get-pip.py | sudo python") + subject.get_pip(machine,pip_install_command) + end end end end \ No newline at end of file