blob: ced1d73dd60d9b7f102b2fe813a5382bb7a1d678 (
plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
---
- name: List configured attribute mappings (that can be used by IdPs)
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }} {% endif %}
mapping list -c ID --format value
run_once: true
changed_when: false
become: true
register: existing_mappings_register
- name: Register existing mappings
set_fact:
existing_mappings: "{{ existing_mappings_register.stdout_lines | map('trim') | list }}"
- name: Remove unmanaged attribute mappings
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-system-scope="all"
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }} {% endif %}
mapping delete {{ item }}
run_once: true
become: true
with_items: "{{ existing_mappings }}"
when:
- item not in (keystone_identity_mappings | map(attribute='name') | list)
- keystone_should_remove_attribute_mappings
- name: Create unexisting domains
become: true
kolla_toolbox:
container_engine: "{{ kolla_container_engine }}"
module_name: "os_keystone_domain"
module_args:
name: "{{ item.openstack_domain }}"
auth: "{{ openstack_auth }}"
endpoint_type: "{{ openstack_interface }}"
cacert: "{{ openstack_cacert }}"
region_name: "{{ openstack_region_name }}"
run_once: true
with_items: "{{ keystone_identity_providers }}"
- name: Register attribute mappings in OpenStack
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface {{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }} {% endif %}
mapping create
--rules "{{ keystone_container_federation_oidc_attribute_mappings_folder }}/{{ item.file | basename }}"
{{ item.name }}
run_once: true
when:
- item.name not in existing_mappings
with_items: "{{ keystone_identity_mappings }}"
- name: Update existing attribute mappings in OpenStack
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }} {% endif %}
mapping set
--rules="{{ keystone_container_federation_oidc_attribute_mappings_folder }}/{{ item.file | basename }}"
{{ item.name }}
run_once: true
when:
- item.name in existing_mappings
with_items: "{{ keystone_identity_mappings }}"
- name: List configured IdPs
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }} {% endif %}
identity provider list -c ID --format value
run_once: true
changed_when: false
register: existing_idps_register
- name: Register existing idps
set_fact:
existing_idps: "{{ existing_idps_register.stdout.split('\n') | map('trim') | list }}"
- name: Remove unmanaged identity providers
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }}{% endif %}
identity provider delete {{ item }}
run_once: true
with_items: "{{ existing_idps }}"
when:
- item not in (keystone_identity_providers | map(attribute='name') | list)
- keystone_should_remove_identity_providers
- name: Register Identity Providers in OpenStack
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }}{% endif %}
identity provider create
--description "{{ item.public_name }}"
--remote-id "{{ item.identifier }}"
--domain "{{ item.openstack_domain }}"
{{ item.name }}
run_once: true
when:
- item.name not in existing_idps
with_items: "{{ keystone_identity_providers }}"
- name: Update Identity Providers in OpenStack according to Kolla-Ansible configurations
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface {{ openstack_interface }}
--os-system-scope "all"
--os-user-domain-name {{ openstack_auth.user_domain_name }}
--os-region-name {{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert {{ openstack_cacert }} {% endif %}
identity provider set
--description "{{ item.public_name }}"
--remote-id "{{ item.identifier }}"
"{{ item.name }}"
run_once: true
when:
- item.name in existing_idps
with_items: "{{ keystone_identity_providers }}"
- name: Configure attribute mappings for each Identity Provider. (We expect the mappings to be configured by the operator)
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }}{% endif %}
federation protocol create
--mapping {{ item.attribute_mapping }}
--identity-provider {{ item.name }}
{{ item.protocol }}
run_once: true
when:
- item.name not in existing_idps
with_items: "{{ keystone_identity_providers }}"
- name: Update attribute mappings for each Identity Provider. (We expect the mappings to be configured by the operator).
become: true
command: >
{{ kolla_container_engine }} exec -t keystone openstack
--os-auth-url={{ openstack_auth.auth_url }}
--os-password={{ openstack_auth.password }}
--os-username={{ openstack_auth.username }}
--os-identity-api-version=3
--os-interface={{ openstack_interface }}
--os-system-scope="all"
--os-user-domain-name={{ openstack_auth.user_domain_name }}
--os-region-name={{ openstack_region_name }}
{% if openstack_cacert != '' %}--os-cacert={{ openstack_cacert }}{% endif %}
federation protocol set
--identity-provider {{ item.name }}
--mapping {{ item.attribute_mapping }}
{{ item.protocol }}
run_once: true
register: result
failed_when: result.rc not in [0, 1] # This command returns RC 1 on success, so we need to add this to avoid fails.
when:
- item.name in existing_idps
with_items: "{{ keystone_identity_providers }}"
|