Skip to content

Commit 2608fd1

Browse files
Fix rotate_app_creds YAML parsing when from_yaml returns a list
The clouds.yaml stored in the OCP secret starts with '---' (from to_nice_yaml), causing from_yaml to return a list instead of a dict. Strip the document separator before piping to the secret and handle both list/dict cases when parsing the verification readback. OSPRH-6485 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent da3299d commit 2608fd1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 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 's/{{ user_cloud }}:/openstack:/' | \
16+
cat {{ clouds_yaml_file_path }} | sed '/^---$/d' | sed 's/{{ user_cloud }}:/openstack:/' | \
1717
oc set data -n kube-system secret/openstack-credentials clouds.yaml=-
1818
environment:
1919
KUBECONFIG: "{{ kubeconfig }}"
@@ -29,8 +29,10 @@
2929
changed_when: false
3030

3131
- name: Parse OCP credentials
32+
vars:
33+
parsed_yaml: "{{ ocp_creds_output.stdout | from_yaml }}"
3234
ansible.builtin.set_fact:
33-
ocp_creds: "{{ ocp_creds_output.stdout | from_yaml }}"
35+
ocp_creds: "{{ (parsed_yaml is mapping) | ternary(parsed_yaml, parsed_yaml[0]) }}"
3436

3537
- name: Verify credentials rotated to application credentials
3638
ansible.builtin.assert:

0 commit comments

Comments
 (0)