openstack-ansible-plugins/roles/service_setup/tasks/setup_roles.yml

52 lines
1.6 KiB
YAML

---
# Copyright 2022, City Network International AB
#
# 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: Add keystone roles
openstack.cloud.identity_role:
cloud: "{{ _service_cloud_name }}"
state: present
name: "{{ role }}"
endpoint_type: admin
validate_certs: "{{ not (_service_adminuri_insecure | default(True) | bool) }}"
register: add_service
until: add_service is success
retries: 5
delay: 10
no_log: "{{ _service_setup_nolog | default(True) }}"
loop: "{{ user_roles }}"
loop_control:
loop_var: role
- name: Add service users to roles
openstack.cloud.role_assignment:
cloud: "{{ _service_cloud_name }}"
state: present
user: "{{ user.name }}"
role: "{{ role }}"
project: "{{ user.project | default(_service_project_name) }}"
domain: "{{ user.domain | default('default') }}"
endpoint_type: admin
validate_certs: "{{ not (_service_adminuri_insecure | default(True) | bool) }}"
register: add_service
until: add_service is success
retries: 5
delay: 10
no_log: "{{ _service_setup_nolog | default(True) }}"
loop: "{{ user_roles }}"
loop_control:
loop_var: role
when:
- "'name' in user"