Skip to content

Commit 7756aed

Browse files
Add pull secret extraction fallback and diagnostics for CI debugging
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent bda356e commit 7756aed

1 file changed

Lines changed: 43 additions & 2 deletions

File tree

collection/tools/roles/tools_get_openshift_release/tasks/get_openshift_release_binaries.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,56 @@
1919
msg: "'openshift_release_pull_spec' must be set by get_openshift_release_build_name.yml"
2020
when: openshift_release_pull_spec is not defined or openshift_release_pull_spec == ''
2121

22-
- name: Extract pull secret from host cluster
22+
- name: Check if rhoso_kubeconfig file exists
23+
ansible.builtin.stat:
24+
path: "{{ rhoso_kubeconfig }}"
25+
register: _rhoso_kubeconfig_stat
26+
27+
- name: Debug kubeconfig and environment info
28+
ansible.builtin.debug:
29+
msg: |
30+
rhoso_kubeconfig path: {{ rhoso_kubeconfig }}
31+
rhoso_kubeconfig exists: {{ _rhoso_kubeconfig_stat.stat.exists }}
32+
home_dir: {{ home_dir }}
33+
KUBECONFIG env: {{ lookup('ansible.builtin.env', 'KUBECONFIG', default='(not set)') }}
34+
35+
- name: Extract pull secret using rhoso_kubeconfig
2336
ansible.builtin.shell: >-
2437
set -o pipefail &&
2538
oc get secret pull-secret -n openshift-config
2639
--kubeconfig={{ rhoso_kubeconfig }}
2740
-o jsonpath='{.data.\.dockerconfigjson}'
2841
| base64 -d > {{ pull_secret_file }}
29-
changed_when: true
42+
register: _pull_secret_rhoso
43+
ignore_errors: true
44+
no_log: true
45+
when: _rhoso_kubeconfig_stat.stat.exists
46+
47+
- name: Extract pull secret using default kubeconfig (fallback)
48+
ansible.builtin.shell: >-
49+
set -o pipefail &&
50+
oc get secret pull-secret -n openshift-config
51+
-o jsonpath='{.data.\.dockerconfigjson}'
52+
| base64 -d > {{ pull_secret_file }}
53+
register: _pull_secret_default
54+
ignore_errors: true
3055
no_log: true
56+
when: _rhoso_kubeconfig_stat.stat.exists == false or _pull_secret_rhoso is failed
57+
58+
- name: Verify pull secret file was created and is valid JSON
59+
ansible.builtin.shell: python3 -c "import json; d=json.load(open('{{ pull_secret_file }}')); print(len(d.get('auths',{})), 'registries found')"
60+
register: _pull_secret_verify
61+
ignore_errors: true
62+
63+
- name: Fail with diagnostic info if pull secret extraction failed
64+
ansible.builtin.fail:
65+
msg: |
66+
Failed to extract pull secret from host cluster.
67+
rhoso_kubeconfig exists: {{ _rhoso_kubeconfig_stat.stat.exists }}
68+
rhoso_kubeconfig result: {{ 'skipped' if _pull_secret_rhoso is skipped else ('ok' if _pull_secret_rhoso is success else 'FAILED rc=' + (_pull_secret_rhoso.rc | default('?') | string)) }}
69+
default kubeconfig result: {{ 'skipped' if _pull_secret_default is skipped else ('ok' if _pull_secret_default is success else 'FAILED rc=' + (_pull_secret_default.rc | default('?') | string)) }}
70+
pull secret validation: {{ _pull_secret_verify.stdout | default('FAILED - ' + _pull_secret_verify.stderr | default('unknown error')) }}
71+
when: _pull_secret_verify is failed
3172

3273
- name: Create the installer directory
3374
ansible.builtin.file:

0 commit comments

Comments
 (0)