ansible / ansible.builtin / v2.16.5 / module / pip Manages Python library dependencies | "added in version" 0.7 of ansible.builtin" Authors: Matt Wright (@mattupstate)ansible.builtin.pip (v2.16.5) — module
pip
Install with pip install ansible-core==2.16.5
Manage Python library dependencies. To use this module, one of the following keys is required: O(name) or O(requirements).
- name: Install bottle python package ansible.builtin.pip: name: bottle
- name: Install bottle python package on version 0.11 ansible.builtin.pip: name: bottle==0.11
- name: Install bottle python package with version specifiers ansible.builtin.pip: name: bottle>0.10,<0.20,!=0.11
- name: Install multi python packages with version specifiers ansible.builtin.pip: name: - django>1.11.0,<1.12.0 - bottle>0.10,<0.20,!=0.11
- name: Install python package using a proxy ansible.builtin.pip: name: six environment: http_proxy: 'http://127.0.0.1:8080' https_proxy: 'https://127.0.0.1:8080'
# You do not have to supply '-e' option in extra_args - name: Install MyApp using one of the remote protocols (bzr+,hg+,git+,svn+) ansible.builtin.pip: name: svn+http://myrepo/svn/MyApp#egg=MyApp
- name: Install MyApp using one of the remote protocols (bzr+,hg+,git+) ansible.builtin.pip: name: git+http://myrepo/app/MyApp
- name: Install MyApp from local tarball ansible.builtin.pip: name: file:///path/to/MyApp.tar.gz
- name: Install bottle into the specified (virtualenv), inheriting none of the globally installed modules ansible.builtin.pip: name: bottle virtualenv: /my_app/venv
- name: Install bottle into the specified (virtualenv), inheriting globally installed modules ansible.builtin.pip: name: bottle virtualenv: /my_app/venv virtualenv_site_packages: yes
- name: Install bottle into the specified (virtualenv), using Python 2.7 ansible.builtin.pip: name: bottle virtualenv: /my_app/venv virtualenv_command: virtualenv-2.7
- name: Install bottle within a user home directory ansible.builtin.pip: name: bottle extra_args: --user
- name: Install specified python requirements ansible.builtin.pip: requirements: /my_app/requirements.txt
- name: Install specified python requirements in indicated (virtualenv) ansible.builtin.pip: requirements: /my_app/requirements.txt virtualenv: /my_app/venv
- name: Install specified python requirements and custom Index URL ansible.builtin.pip: requirements: /my_app/requirements.txt extra_args: -i https://example.com/pypi/simple
- name: Install specified python requirements offline from a local directory with downloaded packages ansible.builtin.pip: requirements: /my_app/requirements.txt extra_args: "--no-index --find-links=file:///my_downloaded_packages_dir"
- name: Install bottle for Python 3.3 specifically, using the 'pip3.3' executable ansible.builtin.pip: name: bottle executable: pip3.3
- name: Install bottle, forcing reinstallation if it's already installed ansible.builtin.pip: name: bottle state: forcereinstall
- name: Install bottle while ensuring the umask is 0022 (to ensure other users can use it) ansible.builtin.pip: name: bottle umask: "0022" become: True
name: description: - The name of a Python library to install or the url(bzr+,hg+,git+,svn+) of the remote package. - This can be a list (since 2.2) and contain version specifiers (since 2.7). elements: str type: list chdir: description: - cd into this directory before running the command type: path version_added: '1.3' version_added_collection: ansible.builtin state: choices: - absent - forcereinstall - latest - present default: present description: - The state of module - The 'forcereinstall' option is only available in Ansible 2.1 and above. type: str umask: description: - The system umask to apply before installing the pip package. This is useful, for example, when installing on systems that have a very restrictive umask by default (e.g., "0077") and you want to pip install packages which are to be used by all users. Note that this requires you to specify desired umask mode as an octal string, (e.g., "0022"). type: str version_added: '2.1' version_added_collection: ansible.builtin version: description: - The version number to install of the Python library specified in the O(name) parameter. type: str editable: default: 'no' description: - Pass the editable flag. type: bool version_added: '2.0' version_added_collection: ansible.builtin executable: description: - The explicit executable or pathname for the pip executable, if different from the Ansible Python interpreter. For example V(pip3.3), if there are both Python 2.7 and 3.3 installations in the system and you want to run pip for the Python 3.3 installation. - Mutually exclusive with O(virtualenv) (added in 2.1). - Does not affect the Ansible Python interpreter. - The setuptools package must be installed for both the Ansible Python interpreter and for the version of Python specified by this option. type: path version_added: '1.3' version_added_collection: ansible.builtin extra_args: description: - Extra arguments passed to pip. type: str version_added: '1.0' version_added_collection: ansible.builtin virtualenv: description: - An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv. type: path requirements: description: - The path to a pip requirements file, which should be local to the remote system. File can be specified as a relative path if using the chdir option. type: str virtualenv_python: description: - The Python executable used for creating the virtual environment. For example V(python3.12), V(python2.7). When not specified, the Python version used to run the ansible module is used. This parameter should not be used when O(virtualenv_command) is using V(pyvenv) or the C(-m venv) module. type: str version_added: '2.0' version_added_collection: ansible.builtin virtualenv_command: default: virtualenv description: - The command or a pathname to the command to create the virtual environment with. For example V(pyvenv), V(virtualenv), V(virtualenv2), V(~/bin/virtualenv), V(/usr/local/bin/virtualenv). type: path version_added: '1.1' version_added_collection: ansible.builtin virtualenv_site_packages: default: 'no' description: - Whether the virtual environment will inherit packages from the global site-packages directory. Note that if this setting is changed on an already existing virtual environment it will not have any effect, the environment must be deleted and newly created. type: bool version_added: '1.0' version_added_collection: ansible.builtin
cmd: description: pip command used by the module returned: success sample: pip2 install ansible six type: str name: description: list of python modules targeted by pip returned: success sample: - ansible - six type: list requirements: description: Path to the requirements file returned: success, if a requirements file was provided sample: /srv/git/project/requirements.txt type: str version: description: Version of the package specified in 'name' returned: success, if a name and version were provided sample: 2.5.1 type: str virtualenv: description: Path to the virtualenv returned: success, if a virtualenv path was provided sample: /tmp/virtualenv type: str