|
13 | 13 | - name: Rotate OpenShift Cloud Credentials |
14 | 14 | ansible.builtin.shell: | |
15 | 15 | 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:/' | \ |
17 | 17 | oc set data -n kube-system secret/openstack-credentials clouds.yaml=- |
18 | 18 | environment: |
19 | 19 | KUBECONFIG: "{{ kubeconfig }}" |
|
22 | 22 | - name: Get OpenStack Credentials from OCP cluster |
23 | 23 | ansible.builtin.shell: | |
24 | 24 | 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 |
26 | 26 | environment: |
27 | 27 | KUBECONFIG: "{{ kubeconfig }}" |
28 | 28 | register: ocp_creds_output |
29 | 29 | changed_when: false |
30 | 30 |
|
| 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 | + |
31 | 35 | - name: Parse OCP credentials |
32 | | - vars: |
33 | | - parsed_yaml: "{{ ocp_creds_output.stdout | from_yaml }}" |
34 | 36 | 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 }}" |
36 | 38 |
|
37 | 39 | - name: Verify credentials rotated to application credentials |
38 | 40 | ansible.builtin.assert: |
39 | 41 | that: |
| 42 | + - ocp_creds is mapping |
| 43 | + - ocp_creds.clouds is defined |
| 44 | + - ocp_creds.clouds.openstack is defined |
40 | 45 | - 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) }}" |
42 | 47 | success_msg: "Credential rotation verified — auth_type is v3applicationcredential" |
43 | 48 |
|
44 | 49 | - name: Wait until the Cluster Operators are healthy |
|
0 commit comments