/home/zuul/src/opendev.org/openstack/openstack-ansible-os_keystone/tasks/keystone_service_bootstrap.yml
---
# 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: Wait for service to be up
  uri:
    url: "http://{{ ansible_host }}:{{ keystone_uwsgi_ports['keystone-wsgi-public']['http'] }}"
    method: "HEAD"
    status_code: 300
  register: _wait_check
  until: _wait_check  is success
  retries: 12
  delay: 5

- name: Bootstrap keystone admin and endpoint
  command: |
     {{ keystone_bin }}/keystone-manage bootstrap \
     --bootstrap-username {{ keystone_admin_user_name }} \
     --bootstrap-password {{ keystone_auth_admin_password }} \
     --bootstrap-project-name {{ keystone_admin_tenant_name }} \
     --bootstrap-role-name {{ keystone_role_name }} \
     --bootstrap-service-name {{ keystone_service_name }} \
     --bootstrap-region-id {{ keystone_service_region }} \
     --bootstrap-admin-url {{ keystone_service_adminuri }} \
     --bootstrap-public-url {{ keystone_service_publicuri }} \
     --bootstrap-internal-url {{ keystone_service_internaluri }}
  no_log: true
  become: yes
  become_user: "{{ keystone_system_user_name }}"
  changed_when: false
  register: add_service
  until: add_service is success
  retries: 5
  delay: 10