Skip to content

Commit a04c57b

Browse files
Fix parsing: use jsonpath for secret read, add debug output for CI visibility
The previous from_yaml fix handled the list case but not the string case. The root cause is the jq + base64 pipeline returning unexpected content. Switch to oc get -o jsonpath for reliable raw value extraction, add debug output to diagnose future parsing issues, and improve the assert to show actual values on failure. OCPBUGS-95045 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 73cf1a3 commit a04c57b

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

collection/stages/roles/day2ops/tasks/procedures/rotate_app_creds.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- name: Rotate OpenShift Cloud Credentials
1414
ansible.builtin.shell: |
1515
set -o pipefail && \
16-
cat {{ clouds_yaml_file_path }} | sed '/^---$/d' | sed 's/{{ user_cloud }}:/openstack:/' | \
16+
sed '/^---$/d' {{ clouds_yaml_file_path }} | sed 's/{{ user_cloud }}:/openstack:/' | \
1717
oc set data -n kube-system secret/openstack-credentials clouds.yaml=-
1818
environment:
1919
KUBECONFIG: "{{ kubeconfig }}"
@@ -22,23 +22,28 @@
2222
- name: Get OpenStack Credentials from OCP cluster
2323
ansible.builtin.shell: |
2424
set -o pipefail && \
25-
oc get secret -n kube-system openstack-credentials -o json | jq -r '.data."clouds.yaml"' | base64 -d
25+
oc get secret -n kube-system openstack-credentials -o jsonpath='{.data.clouds\.yaml}' | base64 -d
2626
environment:
2727
KUBECONFIG: "{{ kubeconfig }}"
2828
register: ocp_creds_output
2929
changed_when: false
3030

31+
- name: Debug OCP credentials output
32+
ansible.builtin.debug:
33+
msg: "Secret content type={{ ocp_creds_output.stdout | from_yaml | type_debug }}, first 200 chars={{ ocp_creds_output.stdout[:200] }}"
34+
3135
- name: Parse OCP credentials
32-
vars:
33-
parsed_yaml: "{{ ocp_creds_output.stdout | from_yaml }}"
3436
ansible.builtin.set_fact:
35-
ocp_creds: "{{ (parsed_yaml is mapping) | ternary(parsed_yaml, parsed_yaml[0]) }}"
37+
ocp_creds: "{{ ocp_creds_output.stdout | from_yaml }}"
3638

3739
- name: Verify credentials rotated to application credentials
3840
ansible.builtin.assert:
3941
that:
42+
- ocp_creds is mapping
43+
- ocp_creds.clouds is defined
44+
- ocp_creds.clouds.openstack is defined
4045
- ocp_creds.clouds.openstack.auth_type == 'v3applicationcredential'
41-
fail_msg: "Credential rotation failed — auth_type is not v3applicationcredential"
46+
fail_msg: "Credential rotation failed — ocp_creds type={{ ocp_creds | type_debug }}, value={{ ocp_creds | to_json | truncate(300) }}"
4247
success_msg: "Credential rotation verified — auth_type is v3applicationcredential"
4348

4449
- name: Wait until the Cluster Operators are healthy

0 commit comments

Comments
 (0)