From 2410119ac9c9f858f2d0ff43d76e8cd61eb5f4f5 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 16 Jan 2020 20:25:46 +0000 Subject: [PATCH] ensure-tox: improve pip detection Fixed issues failing to install tox on python3 only systems which have only pip3 executable and not the pip one. Needed-By: https://review.rdoproject.org/r/#/c/24584/ Change-Id: Ie50928c9b782ea84db916bb1441567e1206ff466 --- roles/ensure-tox/tasks/main.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/ensure-tox/tasks/main.yaml b/roles/ensure-tox/tasks/main.yaml index b2b7487eb..daff0040c 100644 --- a/roles/ensure-tox/tasks/main.yaml +++ b/roles/ensure-tox/tasks/main.yaml @@ -1,2 +1,9 @@ - name: Ensure tox is installed - shell: type tox || pip install --user tox + shell: | + set -euo pipefail + PIP=$(command -v pip pip3 | head -n1) + type tox || $PIP install --user tox + args: + executable: /bin/bash + register: result + changed_when: "'Successfully installed' in result.stdout"