openstack-ansible-os_magnum/tasks/magnum_service_setup.yml

84 lines
3.3 KiB
YAML

---
# Copyright 2016, Ian Cordasco
#
# 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.
# We set the python interpreter to the ansible runtime venv if
# the delegation is to localhost so that we get access to the
# appropriate python libraries in that venv. If the delegation
# is to another host, we assume that it is accessible by the
# system python instead.
# NOTE (noonedeadpunk) We can't move domain creation inside service_setup.yml
# since for role assignment we need to provide ID of created domain instead of
# domain name (which we have). This might be dropped right after backport of
# https://github.com/ansible/ansible/commit/737da1853ef2239e27a2fe380c3e83ba5b34de5b
- name: Setup the service
delegate_to: "{{ magnum_service_setup_host }}"
vars:
ansible_python_interpreter: "{{ magnum_service_setup_host_python_interpreter }}"
block:
- name: Add trustee domain
os_keystone_domain:
cloud: default
state: present
name: "{{ magnum_trustee_domain_name }}"
endpoint_type: admin
verify: "{{ not keystone_service_adminuri_insecure }}"
register: add_trustee_domain
until: add_trustee_domain is success
retries: 5
delay: 10
- import_tasks: service_setup.yml
vars:
_service_adminuri_insecure: "{{ keystone_service_adminuri_insecure }}"
_service_setup_host: "{{ magnum_service_setup_host }}"
_service_setup_host_python_interpreter: "{{ magnum_service_setup_host_python_interpreter }}"
_service_project_name: "{{ magnum_service_project_name }}"
_service_region: "{{ magnum_service_region }}"
_service_users: |-
{% set users = [
{
'name': magnum_service_user_name,
'password': magnum_service_password
},
{
'name': magnum_trustee_domain_admin_name,
'password': magnum_trustee_password,
'domain': magnum_trustee_domain_name
}
]
%}
{% for role in magnum_service_role_names %}
{% set _ = users.append({'name': magnum_service_user_name, 'role': role}) %}
{% endfor %}
{% for role in magnum_trustee_domain_admin_roles %}
{% set _ = users.append({'name': magnum_trustee_domain_admin_name, 'role': role, 'domain': add_trustee_domain.id, 'project': ''}) %}
{% endfor %}
{{ users }}
_service_endpoints:
- service: "{{ magnum_service_name }}"
interface: "public"
url: "{{ magnum_service_publicurl }}"
- service: "{{ magnum_service_name }}"
interface: "internal"
url: "{{ magnum_service_internalurl }}"
- service: "{{ magnum_service_name }}"
interface: "admin"
url: "{{ magnum_service_adminurl }}"
_service_catalog:
- name: "{{ magnum_service_name }}"
type: "{{ magnum_service_type }}"
description: "{{ magnum_service_description }}"