Fix same-host offline install race

When pip_offline_install is used on a deployment such as an AIO where
the host being installed to ie. "aio1" is also the deployment host,
a race condition existed where the pip wheels would be downloaded,
uploaded to the same path on the target host, and then cleaned up
from the deployment host before the installation was continued.

The result is a race condition where the wheels are removed from
the target prior to installation due to the target being local.

This changes the pip offline install cleanup to run as a handler
so the cleanup can take place after the role has completed its work
with the cached wheels.

Change-Id: Ibf36118d42950f0f64f83b6ffc3601c9a241289d
This commit is contained in:
Logan V 2016-10-20 10:51:33 -05:00
parent dad6a5c086
commit d3a2adc67c
3 changed files with 49 additions and 25 deletions

39
handlers/main.yml Normal file
View File

@ -0,0 +1,39 @@
---
# Copyright 2016, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Clean up local get-pip.py
local_action:
module: file
path: "/tmp/get-pip.py"
state: absent
run_once: yes
tags:
- pip-install-cleanup
- name: Clean up local install cache
local_action:
module: file
path: "{{ pip_tmp_packages }}"
state: absent
run_once: yes
tags:
- pip-install-cleanup
- name: Clean up remote install files
file:
path: "{{ pip_tmp_packages }}"
state: absent
tags:
- pip-install-cleanup

View File

@ -26,6 +26,8 @@
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
@ -43,6 +45,8 @@
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
@ -54,6 +58,8 @@
path: "{{ pip_tmp_packages }}"
state: directory
run_once: yes
notify:
- Clean up local install cache
tags:
- pip-install-local
@ -64,6 +70,8 @@
until: pip_local_cache | success
retries: 3
delay: 2
notify:
- Clean up local install cache
- name: Distribute the modern PIP installer
copy:
@ -77,28 +85,12 @@
copy:
src: "{{ pip_tmp_packages }}/"
dest: "{{ pip_tmp_packages }}"
notify:
- Clean up remote install files
tags:
- pip-install-cache-distribute
- pip-install
- name: Clean up local get-pip.py
local_action:
module: file
path: "/tmp/get-pip.py"
state: absent
run_once: yes
tags:
- pip-install-cleanup
- name: Clean up local install cache
local_action:
module: file
path: "{{ pip_tmp_packages }}"
state: absent
run_once: yes
tags:
- pip-install-cleanup
- name: Set source install pip_get_pip_options
set_fact:
pip_source_install_options: "--no-index --find-links={{ pip_tmp_packages | quote }}"

View File

@ -61,10 +61,3 @@
until: install_packages_fall_back | success
retries: 5
delay: 2
- name: Clean up remote install files
file:
path: "{{ pip_tmp_packages }}"
state: absent
tags:
- pip-install-cleanup