Skip to content

Instantly share code, notes, and snippets.

@skyler
Created October 16, 2015 14:48
Show Gist options
  • Save skyler/036f5de9f7a8f8f8d4aa to your computer and use it in GitHub Desktop.
Save skyler/036f5de9f7a8f8f8d4aa to your computer and use it in GitHub Desktop.
Python tasks
---
- name: yum packages for building python
yum: name={{ item }} state=latest
with_items:
- zlib-devel
- bzip2-devel
- openssl-devel
- xz-libs
- name: create work directories
file: path={{ item }} state=directory
with_items:
- "{{ python_build_dir }}"
- "{{ python_build_dir }}/src"
- "{{ python_build_dir }}/setuptools"
- name: download python source
get_url:
url={{ python_download_url }}
dest="{{ python_build_dir }}/python.tgz"
- name: extract python source
command: /bin/tar -xf {{ python_build_dir }}/python.tgz -C {{ python_build_dir }}/src --strip-components=1
- name: build python
command: "{{ item }}"
with_items:
- ./configure --prefix=/usr/local
- /usr/bin/make
- /usr/bin/make altinstall
args:
creates: "{{ python27_bin }}"
chdir: "{{ python_build_dir }}/src"
- name: download setuptools
get_url:
url={{ setuptools_download_url }}
dest="{{ python_build_dir }}/setuptools.tgz"
- name: extract setuptools source
command: /bin/tar -xf {{ python_build_dir }}/setuptools.tgz -C {{ python_build_dir }}/setuptools --strip-components=1
- name: install setuptools
command: "{{ python27_bin }} setup.py install"
args:
chdir: "{{ python_build_dir }}/setuptools"
- name: download pip
get_url:
url={{ pip_download_url }}
dest="{{ python_build_dir }}/get-pip.py"
- name: install pip
command: "{{ python27_bin }} {{ python_build_dir }}/get-pip.py"
- stat: path=/usr/local/bin/npm
register: npm_stat
- name: tell npm to use this version of python
command: /usr/local/bin/npm config set python python2.7
when: npm_stat.stat.exists == True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment