|
33 | 33 | right=$(grep "{{ image }}" "{{ iib_local_folder }}/mapping.txt" | cut -f2 -d=) |
34 | 34 | right_base=$(echo $right | sed -e 's/:.*$//' -e 's/@.*$//') |
35 | 35 | right_log=$(echo "${right_base}@${left_sha}" | sed -e 's/\//-/g') |
36 | | - if skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"{{ image }}" &> /tmp/skopeo-"{{ image | regex_replace('/', '-') }}".log; then |
| 36 | + left_out=$(skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"{{ image }}" 2>&1) |
| 37 | + left_ret=$? |
| 38 | + if [ $left_ret -eq 0 ]; then |
37 | 39 | echo "{{ image }}" |
38 | | - elif skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"${right_base}@${left_sha}" &> "/tmp/skopeo-${right_log}.log"; then |
39 | | - echo "${right_base}@${left_sha}" |
40 | 40 | else |
41 | | - echo "ERROR: both {{ image }} and echo ${right_base}@${left_sha} could not be found" |
42 | | - exit 1 |
| 41 | + echo "${left_out}" > /tmp/skopeo-"{{ image | regex_replace('/', '-') }}".log |
| 42 | + right_out=$(skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"${right_base}@${left_sha}" 2>&1) |
| 43 | + right_ret=$? |
| 44 | + if [ $right_ret -eq 0 ]; then |
| 45 | + echo "${right_base}@${left_sha}" |
| 46 | + else # both left_ret and right_ret were != 0 |
| 47 | + echo "${right_out}" > "/tmp/skopeo-${right_log}.log" |
| 48 | + echo "ERROR: both {{ image }} and echo ${right_base}@${left_sha} could not be found" |
| 49 | + echo "Printing both outputs:" |
| 50 | + echo "Left out: ${left_out}" |
| 51 | + echo "Right out: ${right_out}" |
| 52 | + exit 1 |
| 53 | + fi |
43 | 54 | fi |
44 | 55 | register: all_existing_images |
45 | 56 | with_items: "{{ all_images }}" |
|
91 | 102 | 'mirrordest_nosha': (mirror_dest + item | basename) | regex_replace('@.*$', ''), |
92 | 103 | 'mirrordest_tag': 'tag-' + item | basename | regex_replace('^.*@sha256:', '')}}, recursive=true) }}" |
93 | 104 | loop: "{{ all_images }}" |
94 | | - when: use_internal_registry |
95 | | - |
96 | | -- name: Create dict with full image name+sha -> mirror destination (OCP < 4.13) |
97 | | - ansible.builtin.set_fact: |
98 | | - image_urls: "{{ image_urls | default({}) | combine({item: |
99 | | - {'mirrordest': mirror_dest + '@' + item | basename | regex_replace('^.*@', ''), |
100 | | - 'mirrordest_nosha': mirror_dest, |
101 | | - 'mirrordest_tag': 'tag-' + item | basename | regex_replace('^.*@sha256:', '')}}, recursive=true) }}" |
102 | | - loop: "{{ all_images }}" |
103 | | - when: not use_internal_registry |
104 | 105 |
|
105 | 106 | - name: Create dict with full image name+sha -> image key without sha |
106 | 107 | ansible.builtin.set_fact: |
|
124 | 125 | src: ./templates/imageDigestMirror.yaml.j2 |
125 | 126 | dest: "{{ iib_local_folder }}/imageMirror.yaml" |
126 | 127 | mode: "0644" |
127 | | - when: use_internal_registry |
128 | | - |
129 | | -- name: Template out imageMirror.yaml (OCP < 4.13) |
130 | | - ansible.builtin.template: |
131 | | - src: ./templates/imageContentSourcePolicy.yaml.j2 |
132 | | - dest: "{{ iib_local_folder }}/imageMirror.yaml" |
133 | | - mode: "0644" |
134 | | - when: not use_internal_registry |
135 | 128 |
|
136 | 129 | - name: Template out mirror.map |
137 | 130 | ansible.builtin.template: |
|
0 commit comments