|
15 | 15 | # under the License. |
16 | 16 |
|
17 | 17 | # Pulled-images report (policy view, not node-verified pulls): |
18 | | -# - Load cluster ImageContentSourcePolicy + ImageDigestMirrorSet objects via oc. |
| 18 | +# - Load cluster ImageDigestMirrorSet + ImageTagMirrorSet objects via oc. |
19 | 19 | # - Flatten them into {source, mirror} pairs (repository prefix -> mirror ref). |
20 | 20 | # - For each container/initContainer in selected namespaces, compare the pod |
21 | 21 | # status image string to those prefixes: first matching source rule yields |
|
39 | 39 | state: directory |
40 | 40 | mode: "0755" |
41 | 41 |
|
42 | | - - name: Get ICSP mirror rules |
43 | | - ansible.builtin.command: |
44 | | - cmd: oc get imagecontentsourcepolicy -o json |
45 | | - register: _pulled_report_icsp |
46 | | - failed_when: false |
47 | | - |
48 | 42 | - name: Get IDMS mirror rules |
49 | 43 | ansible.builtin.command: |
50 | 44 | cmd: oc get imagedigestmirrorset -o json |
51 | 45 | register: _pulled_report_idms |
52 | 46 | failed_when: false |
53 | 47 |
|
54 | | - # Flatten ICSP repositoryDigestMirrors and IDMS imageDigestMirrors into |
55 | | - # a single list of {source, mirror} pairs. A source with N mirrors |
56 | | - # produces N entries so the Jinja template can prefix-match every |
57 | | - # mirror in one loop. |
| 48 | + - name: Get ITMS mirror rules |
| 49 | + ansible.builtin.command: |
| 50 | + cmd: oc get imagetagmirrorset -o json |
| 51 | + register: _pulled_report_itms |
| 52 | + failed_when: false |
| 53 | + |
| 54 | + # Flatten IDMS imageDigestMirrors and ITMS imageTagMirrors into a single |
| 55 | + # list of {source, mirror} pairs. A source with N mirrors produces N |
| 56 | + # entries so the Jinja template can prefix-match every mirror in one loop. |
58 | 57 | # Example output (_pulled_report_mirror_mappings): |
59 | 58 | # - source: registry.redhat.io/openstack-k8s-operators |
60 | 59 | # mirror: quay.example.com/rh-osbs/openstack-k8s-operators |
61 | 60 | # - source: registry.redhat.io/openstack-k8s-operators |
62 | 61 | # mirror: internal-registry.corp.net/openstack-k8s-operators |
63 | | - - name: Build source-to-mirror mapping from ICSP/IDMS |
| 62 | + - name: Build source-to-mirror mapping from IDMS/ITMS |
64 | 63 | vars: |
65 | | - _icsp_items: >- |
66 | | - {{ (_pulled_report_icsp.stdout | default('{}', true) | from_json).get('items', []) }} |
67 | 64 | _idms_items: >- |
68 | 65 | {{ (_pulled_report_idms.stdout | default('{}', true) | from_json).get('items', []) }} |
| 66 | + _itms_items: >- |
| 67 | + {{ (_pulled_report_itms.stdout | default('{}', true) | from_json).get('items', []) }} |
69 | 68 | _mappings: >- |
70 | 69 | {% set maps = [] %} |
71 | | - {# ICSP spec.repositoryDigestMirrors: source repo + mirrors[] #} |
72 | | - {% for icsp in _icsp_items %} |
73 | | - {% for rdm in icsp.spec.get('repositoryDigestMirrors', []) %} |
| 70 | + {# IDMS spec.imageDigestMirrors: digest-based mirror rules #} |
| 71 | + {% for idms in _idms_items %} |
| 72 | + {% for rdm in idms.spec.get('imageDigestMirrors', []) %} |
74 | 73 | {% if rdm.source is defined and rdm.source %} |
75 | 74 | {% for m in rdm.get('mirrors', []) %} |
76 | 75 | {% set _ = maps.append({'source': rdm.source, 'mirror': m}) %} |
77 | 76 | {% endfor %} |
78 | 77 | {% endif %} |
79 | 78 | {% endfor %} |
80 | 79 | {% endfor %} |
81 | | - {# IDMS spec.imageDigestMirrors: same shape for matching purposes #} |
82 | | - {% for idms in _idms_items %} |
83 | | - {% for rdm in idms.spec.get('imageDigestMirrors', []) %} |
84 | | - {% if rdm.source is defined and rdm.source %} |
85 | | - {% for m in rdm.get('mirrors', []) %} |
86 | | - {% set _ = maps.append({'source': rdm.source, 'mirror': m}) %} |
| 80 | + {# ITMS spec.imageTagMirrors: tag-based mirror rules #} |
| 81 | + {% for itms in _itms_items %} |
| 82 | + {% for rtm in itms.spec.get('imageTagMirrors', []) %} |
| 83 | + {% if rtm.source is defined and rtm.source %} |
| 84 | + {% for m in rtm.get('mirrors', []) %} |
| 85 | + {% set _ = maps.append({'source': rtm.source, 'mirror': m}) %} |
87 | 86 | {% endfor %} |
88 | 87 | {% endif %} |
89 | 88 | {% endfor %} |
|
92 | 91 | ansible.builtin.set_fact: |
93 | 92 | _pulled_report_mirror_mappings: "{{ _mappings | trim | from_yaml }}" |
94 | 93 |
|
95 | | - - name: Warn if no ICSP/IDMS mirror rules found |
| 94 | + - name: Warn if no IDMS/ITMS mirror rules found |
96 | 95 | when: _pulled_report_mirror_mappings | length == 0 |
97 | 96 | ansible.builtin.debug: |
98 | 97 | msg: >- |
99 | | - No ICSP or IDMS mirror rules found on the cluster. |
| 98 | + No IDMS or ITMS mirror rules found on the cluster. |
100 | 99 | All rows will have expected_pull_basis: source and expected_pull_location from the image ref. |
101 | 100 |
|
102 | 101 | # Namespaces come from role default / caller; failed namespaces skip via failed_when: false. |
|
0 commit comments