Skip to content

Commit 714cfa5

Browse files
committed
add variable to control the versions installed
1 parent 3e54316 commit 714cfa5

4 files changed

Lines changed: 59 additions & 36 deletions

File tree

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
Role Name
2-
=========
1+
python-dev
2+
==========
33

4-
A brief description of the role goes here.
4+
Installs tools commonly used by Python developers, including multiple
5+
versions of the Python interpreter, PyPy, pip, virtualenv,
6+
virtualenvwrapper, tox, and wheel.
57

68
Requirements
79
------------
810

9-
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
11+
None
1012

1113
Role Variables
1214
--------------
1315

14-
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
16+
* python_dev_versions
17+
18+
The versions of python to install, as a list of dictionaries
19+
containing one key "version" and the version number as a
20+
string. Defaults to: [{version: "2.6"}, {version: "3.3"}, {version:
21+
"3.4"}, {version: "2.7"}]
22+
23+
The last version included will be used as the default version for
24+
pip. To use pip with the other versions, add the version number to
25+
the command name (for example, "pip3.3 install mypackage").
1526

1627
Dependencies
1728
------------
1829

19-
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
30+
None
2031

2132
Example Playbook
2233
----------------
@@ -25,7 +36,10 @@ Including an example of how to use your role (for instance, with variables passe
2536

2637
- hosts: servers
2738
roles:
28-
- { role: username.rolename, x: 42 }
39+
- role: username.python-dev
40+
python-versions:
41+
- version: 3.3
42+
- version: 3.4
2943

3044
License
3145
-------
@@ -35,4 +49,4 @@ BSD
3549
Author Information
3650
------------------
3751

38-
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
52+
Doug Hellmann

defaults/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
---
2-
# defaults file for python-dev
2+
python_dev_versions:
3+
- version: "2.6"
4+
- version: "3.3"
5+
- version: "3.4"
6+
- version: "2.7"

tasks/main.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---
2+
- name: Install tools for adding PPA repositories
3+
sudo: yes
4+
apt: name={{ item }} state=latest
5+
with_items:
6+
- python-software-properties
7+
- software-properties-common
28
- name: Install Python dependencies
39
sudo: true
410
apt: name={{ item }} state=latest
@@ -7,17 +13,38 @@
713
- gcc
814
- include: deadsnakes.yml
915
- include: pip.yml
10-
- include: python-version.yml version=2.6
11-
- include: python-version.yml version=3.3
12-
- include: python-version.yml version=3.4
13-
- include: python-version.yml version=2.7
16+
- name: Install python
17+
apt: name=python{{ item.version }} state=latest
18+
sudo: true
19+
with_items: python_dev_versions
20+
- name: Install python-dev
21+
apt: name=python{{ item.version }}-dev state=latest
22+
sudo: true
23+
with_items: python_dev_versions
24+
- name: Install easy_install from source
25+
sudo: yes
26+
command: "python{{item.version}} /tmp/ez_setup.py"
27+
args:
28+
creates: "/usr/local/bin/easy_install-{{item.version}}"
29+
with_items: python_dev_versions
30+
- name: Install pip from source
31+
sudo: yes
32+
command: "python{{item.version}} /tmp/get-pip.py"
33+
args:
34+
creates: "/usr/local/bin/pip{{item.version}}"
35+
with_items: python_dev_versions
36+
- name: Install wheel
37+
sudo: yes
38+
command: "pip{{item.version}} install wheel"
39+
args:
40+
creates: "/usr/local/lib/python{{item.version}}/dist-packages/wheel"
41+
with_items: python_dev_versions
1442
- include: pypy.yml
1543
- name: Install Python tools
1644
pip: name={{ item }}
1745
sudo: true
1846
with_items:
1947
- tox
20-
- detox
2148
- virtualenv
2249
- virtualenvwrapper
2350
- wheel

tasks/python-version.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)