manage_pip_packages/README.md

75 lines
2.5 KiB
Markdown
Raw Permalink Normal View History

manage_pip_packages
2023-03-14 22:23:33 +00:00
=========
2023-07-11 20:51:28 +00:00
> This repository is only a mirror. Development and testing is done on a private gitea server.
2023-03-14 22:01:45 +00:00
2023-04-04 19:33:40 +00:00
This role enables you to manage python packages on **debian-based** distributions. It can be used on its own , or be called by other roles the install/remove packages on demand.
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
Requirements
------------
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
None.
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
Role Variables
--------------
Available variables are listed below, along with default values. A sample file for the default values is available in `default/manage_pip_packages.yml.sample` in case you need it for any `group_vars` or `host_vars` configuration.
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
```yaml
manage_pip_packages_install_prereqs: true # by default, set to true
2023-03-14 22:01:45 +00:00
```
```yaml
2023-04-06 19:22:26 +00:00
manage_pip_packages_list: # by default, not defined
- name: nginx
version_constraint: latest # Leaving empty or setting '' will be considered as latest
state: absent
- name: ...
```
2023-04-06 19:25:21 +00:00
This variable is a list of packages, with their name, desired version and state. `version_constraint` can be multiple constraints,separated by commas (example: `>1.10`, `>1.10,<1.15,!=1.12`,`==1.13`).
2023-03-14 22:01:45 +00:00
2023-08-27 16:13:08 +00:00
```yaml
manage_pip_packages_allow_break_system_packages: false # by default, set to false
```
This variable allow you to pass the `--break_system_packages` to pip.
> **Warning**
2024-02-05 21:27:12 +00:00
> This is not recommended, and is only here if you have no other choice to install packages that aren't supported by the package manager, on distros that enforce the [PEP668](https://peps.python.org/pep-0668/). Chances are you can probably use [manage_pipx_packages](https://github.com/ednz_cloud/manage_pipx_packages) to install packages using pipx, avoiding the potential damages to your system.
2023-08-27 16:13:08 +00:00
2023-03-14 22:23:33 +00:00
Dependencies
------------
2023-03-14 22:01:45 +00:00
2024-02-05 21:27:12 +00:00
`ednz_cloud.manage_apt_packages` to install python3 and pip (if selected).
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
Example Playbook
----------------
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
```yaml
# calling the role inside a playbook with either the default or group_vars/host_vars
- hosts: servers
roles:
2024-02-05 21:27:12 +00:00
- ednz_cloud.manage_pip_packages
2023-03-14 22:23:33 +00:00
```
2023-03-14 22:01:45 +00:00
```yaml
# calling the role inside a playbook and injecting variables (in another role for example)
- hosts: servers
tasks:
- name: "Install ansible with pip"
2023-04-04 19:33:40 +00:00
ansible.builtin.include_role:
2024-02-05 21:27:12 +00:00
name: ednz_cloud.manage_pip_packages
vars:
manage_pip_packages_install_prereqs: false
manage_pip_packages_list:
- name: ansible-core
version_constraint: latest
state: present
```
2023-03-14 22:23:33 +00:00
License
-------
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
MIT / BSD
2023-03-14 22:01:45 +00:00
2023-03-14 22:23:33 +00:00
Author Information
------------------
2023-03-14 22:01:45 +00:00
This role was created by Bertrand Lanson in 2023.