Skip to content

Commit

Permalink
Allow pypiserver to be upgraded before repo build
Browse files Browse the repository at this point in the history
To cater for a situation where the pypiserver package is changing,
but the repo does not yet have the package built, we need to ensure
that the install task for it can fetch from pypi (or the designated
pypi mirror). To do this we try the local repo first, then fall back
to using the designated default index which defaults to pypi.

Change-Id: I1a2d36793fccc4c50f00247c8d19501ad8816517
(cherry picked from commit 4e3213f)
  • Loading branch information
Jesse Pretorius committed Apr 23, 2018
1 parent 22f31de commit c75720f
Showing 1 changed file with 40 additions and 15 deletions.
55 changes: 40 additions & 15 deletions tasks/repo_install.yml
Expand Up @@ -55,19 +55,44 @@
retries: 5
delay: 2

- name: Install pip packages
pip:
name: "{{ repo_pypiserver_pip_packages }}"
state: "{{ repo_server_pip_package_state }}"
virtualenv: "{{ repo_pypiserver_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages | success
retries: 5
delay: 2
notify:
- reload pypiserver
# Note(odyssey4me):
# To cater for a situation where the pip packages are changing, but the repo
# does not yet have the package built, we need to ensure that this task can
# fetch from pypi. To do this we try the local repo first, then fall back to
# using pypi.
- name: Try installing from the repo first, then fall back to using pypi
block:
- name: Install pip packages (from repo)
pip:
name: "{{ repo_pypiserver_pip_packages }}"
state: "{{ repo_server_pip_package_state }}"
virtualenv: "{{ repo_pypiserver_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages | success
retries: 5
delay: 2
notify:
- reload pypiserver
rescue:
- name: Install pip packages (from pypi mirror)
pip:
name: "{{ repo_pypiserver_pip_packages }}"
state: "{{ repo_server_pip_package_state }}"
virtualenv: "{{ repo_pypiserver_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
--index-url {{ repo_build_pip_default_index | default('https://pypi.python.org/simple') }}
--trusted-host {{ (repo_build_pip_default_index | default('https://pypi.python.org/simple')) | netloc_no_port }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages | success
retries: 5
delay: 2
notify:
- reload pypiserver

0 comments on commit c75720f

Please sign in to comment.