|
13 | 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
14 | 14 | # License for the specific language governing permissions and limitations |
15 | 15 | # under the License. |
16 | | - |
17 | | -# --------------------------------------------------------------------------- |
18 | | -# Step 1 - read the Keycloak CA cert written by federation-pre-deploy |
19 | | -# --------------------------------------------------------------------------- |
20 | | -- name: Get ingress operator CA cert |
21 | | - ansible.builtin.slurp: |
22 | | - src: "{{ [ansible_user_dir, 'ci-framework-data', 'tmp', 'ingress-operator-ca.crt'] | path_join }}" |
23 | | - register: federation_sso_ca |
24 | | - |
25 | | -# --------------------------------------------------------------------------- |
26 | | -# Step 2 - read the live OSCP to determine where the CA bundle lives. |
27 | 16 | # |
28 | | -# Priority for the secret name: |
29 | | -# 1. spec.tls.caBundleSecretName already set on the OSCP (use it as-is). |
30 | | -# 2. cifmw_custom_ca_certs_secret_name variable (if set by caller). |
31 | | -# 3. Hard default: "custom-ca-certs". |
| 17 | +# Pre-deploy hook for the component / CRC pipeline. |
32 | 18 | # |
33 | | -# This makes the hook self-healing: it does not rely on the kustomize having |
34 | | -# correctly propagated caBundleSecretName, and it works on fresh installs |
35 | | -# where the secret does not yet exist. |
36 | | -# --------------------------------------------------------------------------- |
37 | | -- name: Read current OpenStackControlPlane state |
38 | | - kubernetes.core.k8s_info: |
39 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
40 | | - api_version: core.openstack.org/v1beta1 |
41 | | - kind: OpenStackControlPlane |
42 | | - name: controlplane |
43 | | - namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
44 | | - register: _federation_oscp_info |
45 | | - |
46 | | -- name: Resolve CA bundle secret name and check if OSCP already references one |
47 | | - ansible.builtin.set_fact: |
48 | | - _federation_ca_bundle_secret_name: >- |
49 | | - {{ |
50 | | - ((_federation_oscp_info.resources | first).spec.tls | default({})).caBundleSecretName |
51 | | - | default(cifmw_custom_ca_certs_secret_name, true) |
52 | | - | default('custom-ca-certs', true) |
53 | | - }} |
54 | | - _federation_oscp_has_ca_bundle: >- |
55 | | - {{ |
56 | | - ( |
57 | | - ((_federation_oscp_info.resources | first).spec.tls | default({})).caBundleSecretName |
58 | | - | default('') |
59 | | - ) | length > 0 |
60 | | - }} |
61 | | -
|
62 | | -# --------------------------------------------------------------------------- |
63 | | -# Step 3 - preserve any keys already in the target secret |
64 | | -# --------------------------------------------------------------------------- |
65 | | -- name: Look up existing CA bundle secret |
66 | | - kubernetes.core.k8s_info: |
67 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
68 | | - api_version: v1 |
69 | | - kind: Secret |
70 | | - name: "{{ _federation_ca_bundle_secret_name }}" |
71 | | - namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
72 | | - register: _federation_existing_ca_bundle |
73 | | - |
74 | | -- name: Capture existing CA bundle secret data |
75 | | - ansible.builtin.set_fact: |
76 | | - _federation_ca_bundle_existing_data: >- |
77 | | - {{ |
78 | | - (_federation_existing_ca_bundle.resources | first).data |
79 | | - if _federation_existing_ca_bundle.resources | length > 0 |
80 | | - else {} |
81 | | - }} |
82 | | -
|
83 | | -# --------------------------------------------------------------------------- |
84 | | -# Step 4 - create / update the secret, adding keycloak-ca.crt |
85 | | -# --------------------------------------------------------------------------- |
86 | | -- name: Create or update CA bundle secret with Keycloak CA cert |
87 | | - kubernetes.core.k8s: |
88 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
89 | | - state: present |
90 | | - definition: |
91 | | - apiVersion: v1 |
92 | | - kind: Secret |
93 | | - type: Opaque |
94 | | - metadata: |
95 | | - name: "{{ _federation_ca_bundle_secret_name }}" |
96 | | - namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
97 | | - data: >- |
98 | | - {{ |
99 | | - _federation_ca_bundle_existing_data | |
100 | | - combine({'keycloak-ca.crt': federation_sso_ca.content}) |
101 | | - }} |
102 | | -
|
103 | | -# --------------------------------------------------------------------------- |
104 | | -# Step 5 - patch the OSCP to reference the secret when not already set |
105 | | -# --------------------------------------------------------------------------- |
106 | | -- name: Patch OpenStackControlPlane to set caBundleSecretName (when unset) |
107 | | - when: not _federation_oscp_has_ca_bundle | bool |
108 | | - kubernetes.core.k8s: |
109 | | - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
110 | | - state: patched |
111 | | - definition: |
112 | | - apiVersion: core.openstack.org/v1beta1 |
113 | | - kind: OpenStackControlPlane |
114 | | - metadata: |
115 | | - name: controlplane |
116 | | - namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
117 | | - spec: |
118 | | - tls: |
119 | | - caBundleSecretName: "{{ _federation_ca_bundle_secret_name }}" |
| 19 | +# Called before kustomize_deploy brings up the OpenStackControlPlane. |
| 20 | +# Creates the required secrets and writes a kustomization file that |
| 21 | +# kustomize_deploy will apply when it deploys the control plane. |
| 22 | +# The OSCP does not exist yet at this point; no direct OSCP patching |
| 23 | +# is performed here. |
| 24 | +# |
| 25 | +# For the post-deploy (architecture / integration / SKMO) pipeline where |
| 26 | +# the OSCP is already running, use hook_controlplane_config_postdeploy.yml |
| 27 | +# instead. |
120 | 28 |
|
121 | | -# --------------------------------------------------------------------------- |
122 | | -# Step 6 - kustomization for CRC/devscripts flow (not consumed by kustomize_deploy) |
123 | | -# --------------------------------------------------------------------------- |
124 | 29 | - name: Ensure kustomization controlplane directory exists |
125 | 30 | ansible.builtin.file: |
126 | 31 | path: "{{ cifmw_manifests_dir }}/kustomizations/controlplane" |
127 | 32 | state: directory |
128 | 33 | mode: "0755" |
129 | 34 |
|
130 | | -- name: Create Keystone federation kustomization |
| 35 | +- name: Create file to customize keystone for Federation resources deployed in the control plane |
131 | 36 | ansible.builtin.copy: |
132 | 37 | dest: "{{ cifmw_manifests_dir }}/kustomizations/controlplane/keystone_federation.yaml" |
133 | 38 | mode: "0644" |
|
141 | 46 | kind: OpenStackControlPlane |
142 | 47 | name: .* |
143 | 48 | patch: |- |
144 | | - apiVersion: core.openstack.org/v1beta1 |
145 | | - kind: OpenStackControlPlane |
146 | | - metadata: |
147 | | - name: controlplane |
148 | | - spec: |
149 | | - tls: |
150 | | - caBundleSecretName: {{ _federation_ca_bundle_secret_name }} |
151 | | - keystone: |
152 | | - template: |
153 | | - httpdCustomization: |
154 | | - customConfigSecret: keystone-httpd-override |
155 | | - customServiceConfig: | |
156 | | - [DEFAULT] |
157 | | - insecure_debug=true |
158 | | - debug=true |
159 | | - [federation] |
160 | | - trusted_dashboard={{ cifmw_federation_horizon_url }}/dashboard/auth/websso/ |
161 | | - [openid] |
162 | | - remote_id_attribute=HTTP_OIDC_ISS |
163 | | - [auth] |
164 | | - methods = password,token,oauth1,mapped,application_credential,openid |
| 49 | + - op: add |
| 50 | + path: /spec/tls |
| 51 | + value: {} |
| 52 | + - op: add |
| 53 | + path: /spec/tls/caBundleSecretName |
| 54 | + value: keycloakca |
| 55 | + - op: add |
| 56 | + path: /spec/keystone/template/httpdCustomization |
| 57 | + value: |
| 58 | + customConfigSecret: keystone-httpd-override |
| 59 | + - op: add |
| 60 | + path: /spec/keystone/template/customServiceConfig |
| 61 | + value: | |
| 62 | + [DEFAULT] |
| 63 | + insecure_debug=true |
| 64 | + debug=true |
| 65 | + [federation] |
| 66 | + trusted_dashboard={{ cifmw_federation_horizon_url }}/dashboard/auth/websso/ |
| 67 | + [openid] |
| 68 | + remote_id_attribute=HTTP_OIDC_ISS |
| 69 | + [auth] |
| 70 | + methods = password,token,oauth1,mapped,application_credential,openid |
165 | 71 |
|
166 | | -# --------------------------------------------------------------------------- |
167 | | -# Step 7 - Keystone httpd override secret (always needed) |
168 | | -# --------------------------------------------------------------------------- |
169 | | -- name: Create Keystone httpd override secret for Federation |
| 72 | +- name: Get ingress operator CA cert |
| 73 | + ansible.builtin.slurp: |
| 74 | + src: "{{ [ansible_user_dir, 'ci-framework-data', 'tmp', 'ingress-operator-ca.crt'] | path_join }}" |
| 75 | + register: cifmw_federation_sso_ca |
| 76 | + |
| 77 | +- name: Add Keycloak CA secret |
170 | 78 | kubernetes.core.k8s: |
171 | 79 | kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
172 | 80 | state: present |
173 | 81 | definition: |
174 | 82 | apiVersion: v1 |
175 | 83 | kind: Secret |
| 84 | + type: Opaque |
176 | 85 | metadata: |
177 | | - name: keystone-httpd-override |
| 86 | + name: keycloakca |
178 | 87 | namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
179 | | - type: Opaque |
180 | | - stringData: |
181 | | - federation.conf: "{{ lookup('template', 'federation-single.conf.j2') }}" |
| 88 | + data: |
| 89 | + KeyCloakCA: "{{ cifmw_federation_sso_ca.content }}" |
182 | 90 |
|
183 | | -# --------------------------------------------------------------------------- |
184 | | -# Step 8 - patch the OSCP for Keystone OIDC settings (kustomize_deploy flow) |
185 | | -# --------------------------------------------------------------------------- |
186 | | -- name: Patch OpenStackControlPlane with Keystone federation config |
187 | | - when: _federation_oscp_info.resources | length > 0 |
| 91 | +- name: Create Keystone httpd override secret for Federation |
188 | 92 | kubernetes.core.k8s: |
189 | 93 | kubeconfig: "{{ cifmw_openshift_kubeconfig }}" |
190 | | - state: patched |
| 94 | + state: present |
191 | 95 | definition: |
192 | | - apiVersion: core.openstack.org/v1beta1 |
193 | | - kind: OpenStackControlPlane |
| 96 | + apiVersion: v1 |
| 97 | + kind: Secret |
194 | 98 | metadata: |
195 | | - name: controlplane |
| 99 | + name: keystone-httpd-override |
196 | 100 | namespace: "{{ cifmw_federation_run_osp_cmd_namespace }}" |
197 | | - spec: |
198 | | - keystone: |
199 | | - template: |
200 | | - httpdCustomization: |
201 | | - customConfigSecret: keystone-httpd-override |
202 | | - customServiceConfig: | |
203 | | - [DEFAULT] |
204 | | - insecure_debug=true |
205 | | - debug=true |
206 | | - [federation] |
207 | | - trusted_dashboard={{ cifmw_federation_horizon_url }}/dashboard/auth/websso/ |
208 | | - [openid] |
209 | | - remote_id_attribute=HTTP_OIDC_ISS |
210 | | - [auth] |
211 | | - methods = password,token,oauth1,mapped,application_credential,openid |
| 101 | + type: Opaque |
| 102 | + stringData: |
| 103 | + federation.conf: "{{ lookup('template', 'federation-single.conf.j2') }}" |
0 commit comments