Skip to content

Commit 40e754a

Browse files
vakwetuClaude Sonnet 4.6
authored andcommitted
[federation] split controlplane hook into pre- and post-deploy
The existing hook_controlplane_config.yml assumed the OpenStackControlPlane (OSCP) was not yet present, which is correct for the component / CRC pipeline. The SKMO integration pipeline runs after kustomize_deploy has already brought up the OSCP, so it needs a different hook that reads the live OSCP, preserves existing CA bundle data, and patches the resource in place. Split into two task files: - hook_controlplane_config.yml (pre-deploy / component pipeline, unchanged) - hook_controlplane_config_postdeploy.yml (post-deploy / SKMO pipeline) Add a new playbook federation-controlplane-config-postdeploy.yml that wraps the new post-deploy task file. The architecture/automation/vars/multi-namespace-skmo.yaml is updated separately to call the new post-deploy playbook. Fix variable names in both task files to use the required cifmw_ prefix so they pass the var-naming[pattern] rule enforced by ansible-lint. Relates-To: OSPCIX-1321 Signed-off-by: Ade Lee <alee@redhat.com> Co-authored-by: Claude Sonnet 4.6 <no-reply@anthropic.com> Made-with: Cursor
1 parent b5f7545 commit 40e754a

3 files changed

Lines changed: 260 additions & 159 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Update CA bundle and patch Keystone for Federation (post-deploy)
3+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
4+
tasks:
5+
- name: Set uni domain name var from federation role
6+
ansible.builtin.set_fact:
7+
cifmw_federation_domain: "apps.ocp.openstack.lab"
8+
when: cifmw_federation_deploy_type == "uni"
9+
10+
- name: Set crc domain name var from federation role
11+
ansible.builtin.set_fact:
12+
cifmw_federation_domain: "apps-crc.testing"
13+
when: cifmw_federation_deploy_type == "crc"
14+
15+
- name: Run SSO controlplane post-deploy setup
16+
ansible.builtin.import_role:
17+
name: federation
18+
tasks_from: hook_controlplane_config_postdeploy.yml

roles/federation/tasks/hook_controlplane_config.yml

Lines changed: 51 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -13,121 +13,26 @@
1313
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1414
# License for the specific language governing permissions and limitations
1515
# 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.
2716
#
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.
3218
#
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.
12028

121-
# ---------------------------------------------------------------------------
122-
# Step 6 - kustomization for CRC/devscripts flow (not consumed by kustomize_deploy)
123-
# ---------------------------------------------------------------------------
12429
- name: Ensure kustomization controlplane directory exists
12530
ansible.builtin.file:
12631
path: "{{ cifmw_manifests_dir }}/kustomizations/controlplane"
12732
state: directory
12833
mode: "0755"
12934

130-
- name: Create Keystone federation kustomization
35+
- name: Create file to customize keystone for Federation resources deployed in the control plane
13136
ansible.builtin.copy:
13237
dest: "{{ cifmw_manifests_dir }}/kustomizations/controlplane/keystone_federation.yaml"
13338
mode: "0644"
@@ -141,71 +46,58 @@
14146
kind: OpenStackControlPlane
14247
name: .*
14348
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
16571
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
17078
kubernetes.core.k8s:
17179
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
17280
state: present
17381
definition:
17482
apiVersion: v1
17583
kind: Secret
84+
type: Opaque
17685
metadata:
177-
name: keystone-httpd-override
86+
name: keycloakca
17887
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 }}"
18290

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
18892
kubernetes.core.k8s:
18993
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
190-
state: patched
94+
state: present
19195
definition:
192-
apiVersion: core.openstack.org/v1beta1
193-
kind: OpenStackControlPlane
96+
apiVersion: v1
97+
kind: Secret
19498
metadata:
195-
name: controlplane
99+
name: keystone-httpd-override
196100
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

Comments
 (0)