Jesse Pretorius 4cef8b6b20 Implement rolling upgrades for nova
Based on [1], this patch implements changes to
the playbook which executes the nova deployment
in a play per host group, serialised to ensure
that:

1. The services are changed in the right order.
2. The API services remain available at all times during
   an upgrade.
3. If services are sharing a host/container then the
   role execution will not execute twice on the same
   host.

[1] https://docs.openstack.org/developer/nova/upgrade.html

Depends-On: I08e5a7f0ce526b11aa52c35ee29c458954a5f22d
Change-Id: I3173962a35b716fd9b0b2a526420fcc5d844befa
2017-07-07 15:54:58 +01:00

46 lines
1.7 KiB
YAML

---
# Copyright 2017, 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.
# This is a generic task set which can be used to execute
# a service action on target hosts for any services. This
# is useful for executing a SIGHUP (reload) to load up any
# configuration changes or to restart services as required.
#
# Inputs:
# - service_name: Any service found matching this prefix will be acted on.
# - service_action: The action to execute [stop, start, restart, reload].
- name: Gather service list
shell: "systemctl list-unit-files --state=enabled --type=service | awk '/{{ service_name }}.* enabled$/ {print $1}'"
args:
executable: "/bin/bash"
register: _enabled_services
changed_when: false
- name: Execute service action
service:
name: "{{ service_file }}"
state: "{{ service_action }}"
with_items: "{{ (_enabled_services.stdout_lines | difference(service_negate | default([]))) | list }}"
loop_control:
loop_var: service_file
- name: Disable the service restart requirement
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: "{{ service_fact | default(service_name) }}"
option: need_service_restart
value: False