2017-05-27 05:09:47 +02:00
# Ansible Role: Pip (for Python)
2020-11-05 22:53:20 +01:00
[![CI ](https://github.com/geerlingguy/ansible-role-pip/workflows/CI/badge.svg?event=push )](https://github.com/geerlingguy/ansible-role-pip/actions?query=workflow%3ACI)
2017-05-27 05:09:47 +02:00
An Ansible Role that installs [Pip ](https://pip.pypa.io ) on Linux.
## Requirements
2017-08-01 05:03:04 +02:00
On RedHat/CentOS, you may need to have EPEL installed before running this role. You can use the `geerlingguy.repo-epel` role if you need a simple way to ensure it's installed.
2017-05-27 05:09:47 +02:00
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml` ):
2020-07-22 19:01:53 +02:00
pip_package: python3-pip
2017-11-14 15:12:37 +01:00
2020-07-22 19:01:53 +02:00
The name of the packge to install to get `pip` on the system. For older systems that don't have Python 3 available, you can set this to `python-pip` .
2017-11-14 15:12:37 +01:00
2020-07-22 19:01:53 +02:00
pip_executable: pip3
2018-11-07 13:25:31 +01:00
2018-11-10 22:04:29 +01:00
The role will try to autodetect the pip executable based on the `pip_package` (e.g. `pip` for Python 2 and `pip3` for Python 3). You can also override this explicitly, e.g. `pip_executable: pip3.6` .
2018-11-07 13:25:31 +01:00
2018-11-10 22:04:29 +01:00
pip_install_packages: []
2018-11-07 13:25:31 +01:00
2017-12-20 06:58:00 +01:00
A list of packages to install with pip. Examples below:
2017-05-27 05:09:47 +02:00
pip_install_packages:
2017-05-27 05:22:04 +02:00
# Specify names and versions.
2017-05-31 05:59:45 +02:00
- name: docker
2017-05-27 05:22:04 +02:00
version: "1.2.3"
- name: awscli
version: "1.11.91"
2017-12-20 06:58:00 +01:00
2017-05-27 05:22:04 +02:00
# Or specify bare packages to get the latest release.
2017-05-31 05:59:45 +02:00
- docker
2017-05-27 05:22:04 +02:00
- awscli
2017-12-20 06:58:00 +01:00
2017-10-31 20:41:59 +01:00
# Or uninstall a package.
- name: docker
state: absent
2017-12-20 06:58:00 +01:00
2021-02-08 12:39:38 +01:00
# Or update a package to the latest version.
2017-10-31 20:41:59 +01:00
- name: docker
state: latest
2017-12-20 06:58:00 +01:00
2017-10-31 20:41:59 +01:00
# Or force a reinstall.
- name: docker
state: forcereinstall
2018-05-01 17:26:17 +02:00
# Or install a package in a particular virtualenv.
- name: docker
virtualenv: /my_app/venv
2017-05-27 05:09:47 +02:00
2022-08-25 15:22:26 +02:00
# Or pass through any extra arguments.
- name: my_special_package_from_my_special_repo
extra_args: --extra-index-url https://my-domain/pypi/pypi-master/simple
2017-05-27 05:09:47 +02:00
## Dependencies
None.
## Example Playbook
- hosts: all
2018-05-01 17:26:17 +02:00
vars:
pip_install_packages:
- name: docker
- name: awscli
2017-05-27 05:09:47 +02:00
roles:
- geerlingguy.pip
## License
MIT / BSD
## Author Information
This role was created in 2017 by [Jeff Geerling ](https://www.jeffgeerling.com/ ), author of [Ansible for DevOps ](https://www.ansiblefordevops.com/ ).