From a990947391b54d1be4d5047ee36afb1064c43e9c Mon Sep 17 00:00:00 2001 From: Viacheslav Ostroukh Date: Wed, 7 Nov 2018 13:25:31 +0100 Subject: [PATCH] add ability to use the role on CentOS 7 --- README.md | 5 +++++ defaults/main.yml | 2 +- tasks/main.yml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 360baa4..cccd741 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ The name of the packge to install to get `pip` on the system. You can set to `py pip_install_packages: [] +The role will try to autodetect pip executable: it will use `pip` for Python 2 and `pip3` for Python 3. You can also override this explicitly: + + pip_executable: pip3.6 + + A list of packages to install with pip. Examples below: pip_install_packages: diff --git a/defaults/main.yml b/defaults/main.yml index 31a85f0..e23b651 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,5 @@ --- # For Python 3, use python3-pip. pip_package: python-pip - +pip_executable: "{{ 'pip3' if pip_package.startswith('python3') else 'pip' }}" pip_install_packages: [] diff --git a/tasks/main.yml b/tasks/main.yml index 0af9d8e..dda7fac 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -10,5 +10,5 @@ version: "{{ item.version | default(omit) }}" virtualenv: "{{ item.virtualenv | default(omit) }}" state: "{{ item.state | default(omit) }}" - executable: "{{ 'pip3' if pip_package == 'python3-pip' else 'pip' }}" + executable: "{{ pip_executable }}" with_items: "{{ pip_install_packages }}"