This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
python_install.yml
58 lines (50 loc) · 1.58 KB
/
python_install.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
# Download/install python
- hosts: all
become: no
vars:
python_version: 2.7.12
tasks:
- file: path=~/src state=directory
- file: path=~/local state=directory
# Get build-depends
- yum: name="{{ item }}" state="latest"
with_items:
- zlib-devel
- bzip2-devel
- gcc
when: ansible_os_family == 'RedHat'
become: yes
- apt: name="{{ item }}" state="latest"
with_items:
- zlib1g-dev
- libbz2-dev
- gcc
when: ansible_os_family == 'Debian'
become: yes
# Download python, get source all setup and ready to build
- stat: path=~/src/Python-{{python_version}}.tgz
register: p
- get_url:
dest: ~/src
url: https://www.python.org/ftp/python/{{python_version}}/Python-{{python_version}}.tgz
when: not p.stat.exists
- stat: path=~/src/Python-{{python_version}}
register: p
- unarchive: copy=no src=~/src/Python-{{python_version}}.tgz dest=~/src creates=~/src/Python-{{python_version}}
when: not p.stat.exists
# Configure
- shell: ./configure --prefix=$HOME/local
args:
chdir: ~/src/Python-{{python_version}}
creates: ~/src/Python-{{python_version}}/Makefile
# Build and install
- shell: make install
args:
chdir: ~/src/Python-{{python_version}}
creates: ~/local/bin/python
# Install pip
- get_url: url=https://bootstrap.pypa.io/get-pip.py dest=~/src/get-pip.py
- shell: ~/local/bin/python ~/src/get-pip.py
# Install virtualenv
- shell: ~/local/bin/pip install virtualenv