openstack-ansible-os_keystone/tasks/keystone_db_setup.yml

55 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
notify:
- Perform a Keystone DB sync contract