Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Set pip to use the pypi-server when locked down
Browse files Browse the repository at this point in the history
The repo server now hosts a native pypi-server. This new server allows
us to use a native pip install instead of our existing "find-links"
approach. Moving to the native pypi server is not only faster, it is also
more scalable. This change agments our existing wheel lockdown by
setting the index to our new pypi-server and defining an online
constraint file in the pip.conf.

Additional checks have been set within the configuration task file so
that we're confirming pip can be locked down prior to setting the
pip.conf file which can, and will break a deployment if configured
incorrectly. These tasks will only fire when the option
`pip_lock_to_internal_repo` has been set to "true" making them a no-op
by default.

Change-Id: I2f9aaa1aecf7d03a833f60d483de364d6a6d64fa
Depends-On: Icc2ee264fc213b258642b5393dd78b1b26ef0542
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
  • Loading branch information
cloudnull committed Feb 10, 2018
1 parent faf690d commit 0f18e40
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
22 changes: 22 additions & 0 deletions tasks/configure.yml
Expand Up @@ -13,6 +13,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Query pip-index
uri:
url: "{{ pip_default_index }}"
method: HEAD
failed_when: false
register: default_index
when:
- pip_lock_to_internal_repo | bool
tags:
- always

- name: Check if pip-index is reachable
fail:
msg: |
The pip index "{{ pip_default_index }}" was unreachable
"{{ default_index.status }}"
when:
- pip_lock_to_internal_repo | bool
- default_index.status != 200
tags:
- always

- name: Create pip config directory
file:
path: "{{ item }}"
Expand Down
23 changes: 15 additions & 8 deletions templates/pip.conf.j2
Expand Up @@ -3,23 +3,30 @@
{% set trusted_host_list = pip_links_host_list | union([ pip_default_index | netloc_no_port ]) %}

[global]
pre = {{ pip_enable_pre_releases }}
timeout = {{ pip_timeout }}
{% if pip_lock_to_internal_repo | bool and pip_links | length > 0 %}
no-index = true
{% else %}
index-url = {{ pip_default_index }}
{% if pip_install_upper_constraints is defined %}
{% set pip_constraint_list = pip_install_upper_constraints.split('--constraint') %}
{% if pip_constraint_list | length > 0 %}
constraint =
{% for pip_constraint in pip_constraint_list %}
{{ pip_constraint.strip() }}
{% endfor %}
{% endif %}
{% endif %}
{% if trusted_host_list | length > 0 %}
trusted-host =
{% for host in trusted_host_list %}
{% for host in trusted_host_list %}
{{ host }}
{% endfor %}
{% endfor %}
{% endif %}

[install]
upgrade = {{ pip_upgrade }}
pre = {{ pip_enable_pre_releases }}
{% if pip_links | length > 0 %}
find-links =
{% for pip_link in pip_links %}
{% for pip_link in pip_links %}
{{ pip_link.link }}
{% endfor %}
{% endfor %}
{% endif %}

0 comments on commit 0f18e40

Please sign in to comment.