refactor(pip): rewrite pip-role

This commit is contained in:
Jadyn Emma Jaeger 2022-01-05 07:02:51 +01:00
parent a2fca9941c
commit 69ab727648
No known key found for this signature in database
GPG key ID: 632410170049FDDA
4 changed files with 38 additions and 4 deletions

3
.gitmodules vendored
View file

@ -1,6 +1,3 @@
[submodule "roles/docker"] [submodule "roles/docker"]
path = roles/docker path = roles/docker
url = https://github.com/geerlingguy/ansible-role-docker.git url = https://github.com/geerlingguy/ansible-role-docker.git
[submodule "roles/pip"]
path = roles/pip
url = https://github.com/geerlingguy/ansible-role-pip.git

@ -1 +0,0 @@
Subproject commit a2c8e54a569d3b3bd92268d6daa0418da123733f

View file

@ -0,0 +1,12 @@
---
# For Python 3, use python3-pip.
pip_package_name: python3-pip
pip_executable: "{{ 'pip3' if pip_package_name.startswith('python3') else 'pip' }}"
pip_executable_extra_args: ~
pip_environment_variables: {}
pip_packages: []
pip_requirements_file: ~
pip_package_state: present
pip_package_virtualenv: ~

26
roles/pip/tasks/main.yml Normal file
View file

@ -0,0 +1,26 @@
---
- name: Ensure Pip is installed.
package:
name: "{{ pip_package_name }}"
state: present
- name: Install packages from list
pip:
name: "{{ item.name | default(item) }}"
version: "{{ item.version | default(omit) }}"
virtualenv: "{{ item.virtualenv | default(omit) }}"
state: "{{ item.state | default(omit) }}"
executable: "{{ pip_executable }}"
extra_args: "{{ pip_executable_extra_args | default(omit) }}"
loop: "{{ pip_packages }}"
environment: "{{ pip_environment_variables }}"
- name: Install packages from requirements file
pip:
requirements: "{{ pip_requirements_file }}"
virtualenv: "{{ pip_package_virtualenv | default(omit) }}"
state: "{{ pip_package_state | default(omit) }}"
executable: "{{ pip_executable }}"
extra_args: "{{ pip_executable_extra_args | default(omit) }}"
when: "pip_requirements_file"
environment: "{{ pip_environment_variables }}"