Jesse Pretorius e98b2d6116 Use a common python build/install role
In order to radically simplify how we prepare the service
venvs, we use a common role to do the wheel builds and the
venv preparation. This makes the process far simpler to
understand, because the role does its own building and
installing. It also reduces the code maintenance burden,
because instead of duplicating the build processes in the
repo_build role and the service role - we only have it all
done in a single place.

We also change the role venv tag var to use the integrated
build's common venv tag so that we can remove the role's
venv tag in group_vars in the integrated build. This reduces
memory consumption and also reduces the duplication.

This is by no means the final stop in the simplification
process, but it is a step forward. The will be work to follow
which:

1. Replaces 'developer mode' with an equivalent mechanism
   that uses the common role and is simpler to understand.
   We will also simplify the provisioning of pip install
   arguments when doing this.
2. Simplifies the installation of optional pip packages.
   Right now it's more complicated than it needs to be due
   to us needing to keep the py_pkgs plugin working in the
   integrated build.
3. Deduplicates the distro package installs. Right now the
   role installs the distro packages twice - just before
   building the venv, and during the python_venv_build role
   execution.

Depends-On: https://review.openstack.org/598957
Change-Id: I18cc964196dbbf5019bc116c41861cb39e466e14
Implements: blueprint python-build-install-simplification
Signed-off-by: Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
2018-09-03 11:11:57 +00:00

123 lines
4.1 KiB
YAML

---
# Copyright 2015, 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: Stop services
service:
name: "{{ item.service_name }}"
enabled: yes
state: "stopped"
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
with_items: "{{ filtered_glance_services }}"
register: _stop
until: _stop is success
retries: 5
delay: 2
listen:
- "Restart glance services"
- "venv changed"
# TODO(odyssey4me):
# Assuming glance-registry is removed in the S cycle as planned, this
# task can be removed in the T cycle.
# Note that this uses shell task because the unit may not exist. When it
# does not exist, the ansible task which stops/disables it fails and it
# is important that we see failures, but get failures in the right
# circumstances.
- name: Stop and disable glance-registry when it is no longer used
shell: |
return_code=0
if [[ "$(systemctl is-active {{ glance_services['glance-registry']['service_name'] }})" == "active" ]]; then
systemctl stop {{ glance_services['glance-registry']['service_name'] }}
return_code=2
fi
if [[ "$(systemctl is-enabled {{ glance_services['glance-registry']['service_name'] }})" == "enabled" ]]; then
systemctl disable {{ glance_services['glance-registry']['service_name'] }}
return_code=2
fi
exit ${return_code}
args:
executable: /bin/bash
when:
- not glance_services['glance-registry']['condition']
register: _remove_glance_service
changed_when: _remove_glance_service.rc == 2
failed_when: _remove_glance_service.rc not in [0, 2]
listen:
- "Restart glance services"
- "venv changed"
# This task causes ansible-lint to give a ANSIBLE0014
# error, which does not make much sense given how the
# environment variable is used in this case.
# TODO(odyssey4me):
# Try to understand the issue ansible-lint is trying
# to highlight and address it.
tags:
- skip_ansible_lint
# TODO(odyssey4me):
# Assuming glance-registry is removed in the S cycle as planned, this
# task can be removed in the T cycle.
- name: Clean up glance-registry init files when they are no longer needed
file:
path: "{{ item }}"
state: absent
with_items:
- "/etc/tmpfiles.d/openstack-{{ glance_services['glance-registry']['service_name'] }}.conf"
- "/etc/systemd/system/{{ glance_services['glance-registry']['service_name'] }}.service"
when:
- not glance_services['glance-registry']['condition']
listen:
- "Restart glance services"
- "venv changed"
# Note (odyssey4me):
# The policy.json file is currently read continually by the services
# and is not only read on service start. We therefore cannot template
# directly to the file read by the service because the new policies
# may not be valid until the service restarts. This is particularly
# important during a major upgrade. We therefore only put the policy
# file in place after the service has been stopped.
#
- name: Copy new policy file into place
copy:
src: "/etc/glance/policy.json-{{ glance_venv_tag }}"
dest: "/etc/glance/policy.json"
owner: "root"
group: "{{ glance_system_group_name }}"
mode: "0640"
remote_src: yes
listen:
- "Restart glance services"
- "venv changed"
- name: Start services
service:
name: "{{ item.service_name }}"
enabled: yes
state: "started"
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
with_items: "{{ filtered_glance_services }}"
register: _start
until: _start is success
retries: 5
delay: 2
listen:
- "Restart glance services"
- "venv changed"
- meta: noop
listen: Manage LB
when: false