diff --git a/.gitmodules b/.gitmodules index a721d9e..c4a5534 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "roles/docker"] path = roles/docker url = https://github.com/geerlingguy/ansible-role-docker.git -[submodule "roles/pip"] - path = roles/pip - url = https://github.com/geerlingguy/ansible-role-pip.git diff --git a/roles/pip b/roles/pip deleted file mode 160000 index a2c8e54..0000000 --- a/roles/pip +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a2c8e54a569d3b3bd92268d6daa0418da123733f diff --git a/roles/pip/defaults/main.yml b/roles/pip/defaults/main.yml new file mode 100644 index 0000000..e688ea2 --- /dev/null +++ b/roles/pip/defaults/main.yml @@ -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: ~ diff --git a/roles/pip/tasks/main.yml b/roles/pip/tasks/main.yml new file mode 100644 index 0000000..891fff0 --- /dev/null +++ b/roles/pip/tasks/main.yml @@ -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 }}"