openstack-ansible-os_keystone/tasks/keystone_db_setup.yml
Jean-Philippe Evrard cee7a02143 Allow the split of install and config
If keystone install is done separately from the config (filtering
or interruption), a re-run of the role will not mark the venv
as changed, and the db sync will not trigger.

Here we force a flush on file next to the venv change, and use
this file (local fact) as a way to know if a db sync is required.

When a dbsync is considered done, i.e after the expand and migrate
stages, we mark the db_migrate as done for all the nodes.

Change-Id: I318700582a65cc1ea6571d9460fd58bed949a4e9
Depends-On: Ie4a47e85bf31e1ac3a2bd6f0dec510bb24abdbbd
2017-04-03 14:05:07 +00:00

56 lines
1.9 KiB
YAML

---
# Copyright 2014, 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: Ensure keystone service stopped on first node
service:
name: "{{ item }}"
state: stopped
register: keystone_stop
failed_when:
- keystone_stop.msg is defined
- "'no service or tool' not in keystone_stop.msg"
- "'systemd could not find' not in keystone_stop.msg"
- "'Could not find the requested service' not in keystone_stop.msg"
with_items:
- "{{ keystone_wsgi_program_names }}"
- "{{ keystone_system_service_name }}"
- name: Check current state of Keystone DB
command: "{{ keystone_bin }}/keystone-manage db_sync --check"
register: keystone_db_sync_check
failed_when: keystone_db_sync_check.rc == 1
changed_when: "{{ keystone_db_sync_check.rc not in [2, 3, 4] }}"
- name: Perform a Keystone DB sync expand
command: "{{ keystone_bin }}/keystone-manage db_sync --expand"
become: yes
become_user: "{{ keystone_system_user_name }}"
when: keystone_db_sync_check.rc == 2
- name: Perform a Keystone DB sync migrate
command: "{{ keystone_bin }}/keystone-manage db_sync --migrate"
become: yes
become_user: "{{ keystone_system_user_name }}"
when: "{{ keystone_db_sync_check.rc in [2, 3] }}"
notify:
- Perform a Keystone DB sync contract
- name: Check if Keystone DB sync contract is required
command: "true"
changed_when: keystone_db_sync_check.rc == 4
register: dbsync
notify:
- Perform a Keystone DB sync contract