-
Notifications
You must be signed in to change notification settings - Fork 47
/
main.yml
72 lines (60 loc) · 2.56 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright 2023 Cloudera, 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: Conditionally load in variables for initializing IPA
ansible.builtin.include_vars:
file: freeipa.yml
when:
- freeipa_activated
- cloudera_manager_external_auth is undefined
- cloudera_manager_version is version('6.0.0','>=')
- name: Select external auth provider details
set_fact:
auth_provider: "{{ auth_providers[cloudera_manager_external_auth.provider] }}"
when: cloudera_manager_external_auth.provider is defined and cloudera_manager_version is version('6.0.0','>=')
- name: Set Cloudera Manager external auth configs
include_role:
name: cloudera.cluster.cloudera_manager.config
vars:
api_config_keys_uppercase: True
api_configs: "{{ lookup('template', 'external_auth_configs.j2') | from_yaml }}"
when: auth_provider is defined and cloudera_manager_version is version('6.0.0','>=')
- block:
- name: Get auth roles from Cloudera Manager
cloudera.cluster.cm_api:
endpoint: /authRoles
register: response
- name: Create auth role name to UUID mapping
set_fact:
auth_role_uuids: "{{ response.json['items'] | items2dict(key_name='name', value_name='uuid') }}"
## BUG: Can't set all mappings in one API call because of OPSAPS-56242
# - name: Set Cloudera Manager external auth user to role mappings
# cloudera.cluster.cm_api:
# endpoint: /externalUserMappings
# body: "{{ lookup('template', 'external_auth_mappings.j2', convert_data=False) }}"
# method: POST
# when: cloudera_manager_external_auth.role_mappings is defined
- name: Set Cloudera Manager external auth user to role mappings
include_tasks: create_mapping.yml
loop: "{{ cloudera_manager_external_auth.role_mappings }}"
loop_control:
loop_var: role_mapping
- name: Restart Cloudera Manager server
service:
name: cloudera-scm-server
state: restarted
become: yes
notify:
- wait cloudera-scm-server
when: cloudera_manager_external_auth.role_mappings is defined and cloudera_manager_version is version('6.0.0','>=')