2e28d75956
Print python_version to the console for debugging purposes and fix the python2 check condition. Change-Id: I31511d5ac848f4648b230221e1e11f711fb6b918
65 lines
1.6 KiB
YAML
65 lines
1.6 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: get python version
|
|
command: "python --version"
|
|
register: python_version
|
|
|
|
- name: Print python version
|
|
debug:
|
|
var: python_version
|
|
|
|
- name: download get-pip.py for python 2.7
|
|
get_url: url=https://bootstrap.pypa.io/pip/2.7/get-pip.py dest=/tmp
|
|
when: '"2.7" in python_version.stderr'
|
|
|
|
- name: download get-pip.py for ptython 2.6
|
|
get_url: url=https://bootstrap.pypa.io/pip/2.6/get-pip.py dest=/tmp
|
|
when: '"2.6" in python_version.stderr'
|
|
|
|
- name: install pip
|
|
become: true
|
|
command: "python /tmp/get-pip.py"
|
|
|
|
- name: delete get-pip.py
|
|
file: state=absent path=/tmp/get-pip.py
|