openstack-ansible-os_swift/tasks/swift_pypy_setup.yml
Anton Khaldin 9d30bb30b9 Only install to virtual environment
Remove all tasks and variables related to toggling between installation
of swift inside or outside of a Python virtual environment.
Installing within a venv is now the only supported deployment.

Additionally, a few changes have been made to make the creation of the
venv more resistant to interruptions during a run of the role.
* unarchiving a pre-built venv will now also occur when the venv
  directory is created, not only after being downloaded
* virtualenv-tools is run against both pre-built and non pre-built venvs
  to account for interruptions during or prior to unarchiving

Change-Id: Id2a27c082a5eb4eddc9eacde9de30f4e61f9ec36
Implements: blueprint only-install-venvs
2016-07-08 03:15:37 -07:00

87 lines
2.6 KiB
YAML

---
# Copyright 2016, Rackspace US, Inc.
#
# 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: Download pre-built pypy
get_url:
url: "{{ swift_pypy_archive['url'] }}"
sha256sum: "{{ swift_pypy_archive['sha256'] }}"
dest: "/var/cache/{{ swift_pypy_archive['url'] | basename }}"
force: yes
- name: Create pypy dir
file:
path: "/opt/pypy-runtime"
state: directory
- name: Set pypy version fact
set_fact:
swift_pypy_version: "{{ swift_pypy_archive['url'] | basename | replace('.tar.bz2', '') }}"
- name: Set pypy env fact
set_fact:
swift_pypy_env: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
- name: Unarchive pre-built pypy
unarchive:
src: "/var/cache/{{ swift_pypy_archive['url'] | basename }}"
dest: "/opt/pypy-runtime"
copy: "no"
creates: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
register: local_pypy
- name: Setup local pypy
command: "{{ item }}"
with_items:
- "{{ swift_pypy_env }} /opt/get-pip.py"
- "{{ swift_pypy_env | dirname }}/pip install --upgrade virtualenv"
when:
- local_pypy | changed
- name: Check for pypy venv
stat:
path: "{{ swift_bin | dirname }}/{{ swift_pypy_version }}-inuse"
get_md5: False
register: local_pypy_venv_stat
- name: Remove existing venv if not pypy setup
file:
path: "{{ swift_bin | dirname }}"
state: absent
when: not local_pypy_venv_stat.stat.exists | bool
- name: Install pip packages into pypy venv
pip:
name: "{{ item }}"
state: latest
virtualenv: "{{ swift_bin | dirname }}"
virtualenv_site_packages: "no"
virtualenv_command: "{{ swift_pypy_env | dirname }}/virtualenv"
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ swift_pip_packages }}"
notify:
- Restart swift account services
- Restart swift container services
- Restart swift object services
- Restart swift proxy services
- name: Mark swift venv for use with pypy
file:
path: "{{ swift_bin | dirname }}/{{ swift_pypy_version }}-inuse"
state: "touch"