openstack-ansible-pip_install/tasks/install_offline.yml

103 lines
2.9 KiB
YAML

---
# 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.
- block:
- name: Get Modern PIP to local
local_action:
module: get_url
url: "{{ pip_upstream_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
register: get_pip_local
until: get_pip_local is success
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
rescue:
- name: Get Modern PIP using fallback URL to local
local_action:
module: get_url
url: "{{ pip_fallback_url }}"
dest: "/tmp/get-pip.py"
force: "yes"
validate_certs: "{{ pip_validate_certs }}"
when: get_pip_local is failed
register: get_pip_local_fallback
until: get_pip_local_fallback is success
retries: 5
delay: 2
run_once: yes
notify:
- Clean up local get-pip.py
tags:
- pip-install-local
- pip-install-script
- name: Create local pip package cache
local_action:
module: file
path: "{{ pip_tmp_packages }}"
state: directory
run_once: yes
notify:
- Clean up local install cache
tags:
- pip-install-local
- name: pip cache install files locally
local_action: >
command python /tmp/get-pip.py
-d '{{ pip_tmp_packages | quote }}'
{{ (pip_install_upper_constraints is defined) |
ternary('--constraint ' ~ pip_install_upper_constraints | default(''), '') }}
{{ pip_get_pip_options }}
{{ pip_packages | map('quote') | join (' ') }}
changed_when: pip_local_cache.stdout.find('Successfully downloaded') != -1
register: pip_local_cache
until: pip_local_cache is success
retries: 3
delay: 2
notify:
- Clean up local install cache
- name: Distribute the modern PIP installer
copy:
src: "/tmp/get-pip.py"
dest: "/opt/get-pip.py"
tags:
- pip-install-local
- pip-install-script
- name: Distribute PIP install files
copy:
src: "{{ pip_tmp_packages }}/"
dest: "{{ pip_tmp_packages }}"
notify:
- Clean up remote install files
tags:
- pip-install-cache-distribute
- pip-install
- name: Set source install pip_get_pip_options
set_fact:
pip_source_install_options: "--no-index --find-links={{ pip_tmp_packages | quote }}"