Skip to content

Commit 45b72cd

Browse files
author
choglundsp
authored
Merge pull request #1 from singleplatform-eng/add_task_for_system_pip_config
adding task for system python_pip_config
2 parents cb3b7e1 + 625b6dd commit 45b72cd

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

defaults/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ python_apt_repo: ''
66
python_global_packages: []
77
python_package_name: python
88

9+
# Example pip configuration
10+
#python_pip_config:
11+
# global:
12+
# index-url: http://pypi.example.com/simple
13+
# find-links:
14+
# - http://pypi2.example.com/simple
15+
# - http://pypi3.example.com/simple
16+
# search:
17+
# index: http://pypi.example.com/simple
18+
919
# Build defaults
1020
python_build_from_source: false
1121
python_configure_prefix: '/usr/local'

tasks/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
- name: Upgrade pip
2626
pip: name=pip state=latest executable="{{python_pip_path}}"
2727

28+
- name: Add system pip.conf
29+
template:
30+
src: pip.conf.j2
31+
dest: /etc/pip.conf
32+
owner: root
33+
group: root
34+
mode: 0644
35+
when: python_pip_config is defined
36+
2837
# Install packages
2938
- name: Install/upgrade virtualenv
3039
pip: name=virtualenv state=latest executable="{{python_pip_path}}"

templates/pip.conf.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% for section,config in python_pip_config.iteritems() | sort %}
2+
[{{section}}]
3+
{% for k,v in config.iteritems() | sort %}
4+
{% if v is iterable and v is not string %}
5+
{{k}} =
6+
{% for item in v %}
7+
{{item}}
8+
{% endfor %}
9+
{% else %}
10+
{{k}} = {{v}}
11+
{% endif %}
12+
{% endfor %}
13+
{% endfor %}

0 commit comments

Comments
 (0)