Simplify and optimise cinder tasks
The upgrade fact set was more complex than it needed to be, and we can use better inventory scoping combined with ansible_play_hosts in order to make the execution more friendly to limited execution. We also cater for setting facts even if the new role is being used without the venv changing. Depends-On: I90d09fe354d87b099024019ceeb2b7e129ef35d0 Change-Id: I97ace7c89dc7015e2e740516695d4e61971cf020
This commit is contained in:
parent
631521139c
commit
8f1781a655
29
tasks/cinder_cleanup_old_facts.yml
Normal file
29
tasks/cinder_cleanup_old_facts.yml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# TODO(odyssey4me):
|
||||
# This file and the task calling it may be removed in Queens.
|
||||
|
||||
- name: Remove the old db_sync fact
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: "need_db_sync"
|
||||
state: absent
|
||||
|
||||
- name: refresh local facts
|
||||
setup:
|
||||
filter: ansible_local
|
||||
gather_subset: "!all"
|
@ -17,28 +17,7 @@
|
||||
command: "{{ cinder_bin }}/cinder-manage db sync"
|
||||
become: yes
|
||||
become_user: "{{ cinder_system_user_name }}"
|
||||
when:
|
||||
- "ansible_local['openstack_ansible']['cinder']['need_db_sync'] | bool"
|
||||
changed_when: false
|
||||
register: dbsync
|
||||
|
||||
- name: Disable the db sync requirement
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: need_db_sync
|
||||
value: False
|
||||
when:
|
||||
- dbsync | succeeded
|
||||
|
||||
- name: Record the need for online data migrations
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: need_online_data_migrations
|
||||
value: True
|
||||
when:
|
||||
- dbsync | succeeded
|
||||
|
||||
- name: Perform online data migrations
|
||||
command: "{{ cinder_bin }}/cinder-manage db online-data-migrations"
|
||||
@ -58,4 +37,3 @@
|
||||
value: False
|
||||
when:
|
||||
- data_migrations | succeeded
|
||||
|
||||
|
@ -112,35 +112,23 @@
|
||||
virtualenv-tools --update-path=auto --reinitialize {{ cinder_bin | dirname }}
|
||||
when: cinder_get_venv | changed
|
||||
|
||||
- name: Record the need for a db sync
|
||||
- name: Initialise the upgrade facts
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: need_db_sync
|
||||
value: True
|
||||
when: cinder_get_venv | changed or
|
||||
cinder_venv_dir | changed or
|
||||
install_packages | changed
|
||||
|
||||
- name: Initialise the online data migration local fact
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: need_online_data_migrations
|
||||
value: False
|
||||
when: cinder_get_venv | changed or
|
||||
cinder_venv_dir | changed or
|
||||
install_packages | changed
|
||||
|
||||
- name: Record the need for a service restart
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: need_service_restart
|
||||
value: True
|
||||
when: cinder_get_venv | changed or
|
||||
cinder_venv_dir | changed or
|
||||
install_packages | changed
|
||||
option: "{{ item }}"
|
||||
value: "True"
|
||||
with_items:
|
||||
- "need_online_data_migrations"
|
||||
- "need_service_restart"
|
||||
when: (cinder_get_venv | changed) or
|
||||
(cinder_venv_dir | changed) or
|
||||
(install_packages | changed) or
|
||||
(ansible_local is not defined) or
|
||||
('openstack_ansible' not in ansible_local) or
|
||||
('cinder' not in ansible_local['openstack_ansible']) or
|
||||
('need_online_data_migrations' not in ansible_local['openstack_ansible']['cinder']) or
|
||||
('need_service_restart' not in ansible_local['openstack_ansible']['cinder'])
|
||||
|
||||
- name: Record the venv tag deployed
|
||||
ini_file:
|
||||
|
@ -40,21 +40,33 @@
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
- include: cinder_cleanup_old_facts.yml
|
||||
when:
|
||||
- "'need_db_sync' in ansible_local['openstack_ansible']['cinder']"
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
- include: cinder_post_install.yml
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
- include: cinder_db_setup.yml
|
||||
static: no
|
||||
when:
|
||||
- "'cinder_api' in group_names"
|
||||
- "inventory_hostname == ansible_play_hosts[0]"
|
||||
when:
|
||||
- groups['cinder_api'] | length > 0
|
||||
- inventory_hostname == groups['cinder_api'][0]
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
- include: cinder_service_setup.yml
|
||||
static: no
|
||||
when:
|
||||
- "'cinder_api' in group_names"
|
||||
- "inventory_hostname == ansible_play_hosts[0]"
|
||||
when:
|
||||
- groups['cinder_api'] | length > 0
|
||||
- inventory_hostname == groups['cinder_api'][0]
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
@ -66,15 +78,18 @@
|
||||
meta: flush_handlers
|
||||
|
||||
- include: cinder_backends.yml
|
||||
static: no
|
||||
when:
|
||||
- "'cinder_volume' in group_names"
|
||||
- "inventory_hostname == ansible_play_hosts[0]"
|
||||
when:
|
||||
- groups['cinder_volume'] | length > 0
|
||||
- inventory_hostname == groups['cinder_volume'][0]
|
||||
tags:
|
||||
- cinder-config
|
||||
|
||||
- include: cinder_lvm_config.yml
|
||||
when:
|
||||
- inventory_hostname in groups['cinder_volume']
|
||||
- cinder_backend_lvm_inuse
|
||||
- "'cinder_volume' in group_names"
|
||||
- "cinder_backend_lvm_inuse | bool"
|
||||
tags:
|
||||
- cinder-config
|
||||
|
Loading…
Reference in New Issue
Block a user