ansible-role-refstack-client/tasks/install-packages.yaml
Martin Kopec 3d592d6a8b Look for python3 by default
This patch improves the required package installing task - search
first for a py3 and verify a virtualenv package is installed too.
If no py3, check py2 and py2 virtualenv respectively.

Change-Id: I7abc59f2edb0c4409ea67ac4b611a95779bef714
2020-12-10 00:32:53 +00:00

52 lines
1.2 KiB
YAML

---
- name: Is python3 available
command: "python3 --version"
ignore_errors: true
register: python3_is_available
changed_when: false
- name: Is python2 available
command: "python2 --version"
ignore_errors: true
changed_when: false
when: python3_is_available.failed
- name: Install git
become: true
package:
name: git
- name: Install virtualenv (py3)
become: true
package:
name: python3-virtualenv
when: not python3_is_available.failed
- name: Install virtualenv (py2)
become: true
package:
name: python-virtualenv
when: python3_is_available.failed
- name: Check if pip is already installed
command: "pip --version"
ignore_errors: true
register: pip_is_installed
when: python3_is_available.failed
# pip3 is a dependency of a python3 package, so if there is a python3
# installed, pip3 should be installed already as well
- when:
- python3_is_available.failed
- pip_is_installed.rc != 0
block:
- name: download get-pip.py
get_url: url=https://bootstrap.pypa.io/get-pip.py dest=/tmp
- name: install pip
become: true
command: "python /tmp/get-pip.py"
- name: delete get-pip.py
file: state=absent path=/tmp/get-pip.py