Sha256: 5be5560203b37da249d4e22384c6f09adb7ca5444a7f9b4a6df7b59abd1dc218

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

module VagrantPlugins
  module Ansible
    module Cap
      module Guest
        module Pip

          DEFAULT_PIP_INSTALL_CMD = "curl https://bootstrap.pypa.io/get-pip.py | sudo python".freeze

          def self.pip_install(machine, package = "", version = "", pip_args = "", upgrade = true)
            upgrade_arg = "--upgrade" if upgrade
            version_arg = ""

            if !version.to_s.empty? && version.to_s.to_sym != :latest
              version_arg = "==#{version}"
            end

            args_array = [pip_args, upgrade_arg, "#{package}#{version_arg}"]
            args_array.reject! { |a| a.nil? || a.empty? }

            pip_install = "pip install"
            pip_install += " #{args_array.join(' ')}" unless args_array.empty?

            machine.communicate.sudo pip_install
          end

          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.
            # Typecast added in the check for safety.

            if pip_install_cmd.to_s.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

        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.3.3.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.3.2.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.19.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.18.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.16.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.14.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.10.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.9.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.8.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb
vagrant-unbundled-2.2.7.0 plugins/provisioners/ansible/cap/guest/pip/pip.rb