diff --git a/README.md b/README.md index c2d3f23..9f6b089 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,14 @@ manage_pip_packages_list: # by default, not defined ``` 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`). +```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** +> 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/ednxzu/manage_pipx_packages) to install packages using pipx, avoiding the potential damages to your system. + Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index 566e0a0..b083ba9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -5,3 +5,4 @@ manage_pip_packages_list: - name: pip version_constraint: latest state: present +manage_pip_packages_allow_break_system_packages: false diff --git a/defaults/manage_pip_packages.yml.sample b/defaults/manage_pip_packages.yml.sample index 1916eb2..97a80c2 100644 --- a/defaults/manage_pip_packages.yml.sample +++ b/defaults/manage_pip_packages.yml.sample @@ -5,3 +5,4 @@ # - name: pip # version_constraint: latest # state: present +# manage_pip_packages_allow_break_system_packages: false \ No newline at end of file diff --git a/molecule/with_custom_packages/group_vars/all.yml b/molecule/with_custom_packages/group_vars/all.yml index c6f3ab8..65ab86b 100644 --- a/molecule/with_custom_packages/group_vars/all.yml +++ b/molecule/with_custom_packages/group_vars/all.yml @@ -10,3 +10,4 @@ manage_pip_packages_list: - name: vault-cli version_constraint: '<3.1.0' state: present +manage_pip_packages_allow_break_system_packages: false diff --git a/tasks/main.yml b/tasks/main.yml index dc7200a..c1e54c2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,6 +8,7 @@ ansible.builtin.pip: name: "{{ item.name }}{% if item.version_constraint not in [None, '', 'latest'] %}{{ item.version_constraint }}{% endif %}" state: "{{ item.state }}" + extra_args: "{% if manage_pip_packages_allow_break_system_packages %}--break-system-packages{% endif %}" loop: "{{ manage_pip_packages_list }}" when: manage_pip_packages_list is defined and manage_pip_packages_list not in [None, '']