Ansible role to manage python package with pip on debian-based systems. https://ednz.fr
Go to file
Bertrand Lanson 35da3a0870
All checks were successful
test / Linting (push) Successful in 31s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m13s
test / Molecule tests (default, debian12) (push) Successful in 1m37s
test / Molecule tests (default, debian11) (push) Successful in 1m40s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m9s
test / Molecule tests (with_custom_packages, debian12) (push) Successful in 1m18s
test / Molecule tests (with_custom_packages, debian11) (push) Successful in 1m21s
test / Molecule tests (with_custom_packages, ubuntu2004) (push) Successful in 59s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Successful in 1m13s
feat(task): do not try to update pip if manage_pip_packages_allow_break_system_packages is true
It might fail on newer distribution (ubuntu 24+, debian 12+), because of the stupid PEP668
2024-09-01 14:19:47 +00:00
.gitea/workflows added ansible verify stage and gitea actions 2023-07-11 20:05:36 +02:00
.github/workflows feat(core): change namespace 2024-02-05 22:27:12 +01:00
defaults added option to bypass pep668 error 2023-08-27 18:13:08 +02:00
handlers added skeleton 2023-03-14 23:23:33 +01:00
meta feat(core): change namespace 2024-02-05 22:27:12 +01:00
molecule feat(core): change namespace 2024-02-05 22:27:12 +01:00
tasks feat(task): do not try to update pip if manage_pip_packages_allow_break_system_packages is true 2024-09-01 14:19:47 +00:00
vars remove auto-install dependencies to get more standard role 2023-08-01 19:29:32 +02:00
.ansible-lint added skeleton 2023-03-14 23:23:33 +01:00
.gitignore ignore .vscode 2023-05-21 20:17:53 +02:00
.yamllint added skeleton 2023-03-14 23:23:33 +01:00
LICENSE added ansible verify stage and gitea actions 2023-07-11 20:05:36 +02:00
README.md feat(core): change namespace 2024-02-05 22:27:12 +01:00

manage_pip_packages

This repository is only a mirror. Development and testing is done on a private gitea server.

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.

Requirements

None.

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.

manage_pip_packages_install_prereqs: true # by default, set to true
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: ...

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).

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

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. Chances are you can probably use manage_pipx_packages to install packages using pipx, avoiding the potential damages to your system.

Dependencies

ednz_cloud.manage_apt_packages to install python3 and pip (if selected).

Example Playbook

# calling the role inside a playbook with either the default or group_vars/host_vars
- hosts: servers
  roles:
    - ednz_cloud.manage_pip_packages
# calling the role inside a playbook and injecting variables (in another role for example)
- hosts: servers
  tasks:
    - name: "Install ansible with pip"
      ansible.builtin.include_role:
        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

License

MIT / BSD

Author Information

This role was created by Bertrand Lanson in 2023.