Skip to content

Commit 25b4574

Browse files
danpawlikopenshift-merge-bot[bot]
authored andcommitted
[build_containers] Fix podman_image push dest for FQDN image names
The containers-built.log contains a list of images as registry/namespace/repository. The containers.podman.podman_image module treats a two-part dest (host/namespace) as a prefix and appends the entire local image name, which produced nested repo names on quay.rdoproject.org. Pass a complete dest (registry, namespace, repository basename, and tag) so Podman pushes to the intended repository. Commit also include a changes that remove calling {{ item }} when loop is used and reduce using `cat` command with `grep` - we can directly call `grep` without `cat`. One more change also done in this commit was to rename tasks that contains wrong script name, that makes confusion. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent 901c0e2 commit 25b4574

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

roles/build_containers/tasks/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
- name: Install tcib
2828
ansible.builtin.import_tasks: install.yml
2929

30-
- name: Generate container_build.sh script
30+
- name: Generate build_containers.sh script
3131
ansible.builtin.template:
3232
src: templates/build_containers.sh.j2
3333
dest: "{{ cifmw_build_containers_basedir }}/artifacts/build_containers.sh"
3434
mode: "0777"
3535
force: true
3636

37-
- name: Run container_build.sh script
37+
- name: Run build_containers.sh script
3838
when: not cifmw_build_containers_run_hotfix | bool
3939
become: true
4040
environment:

roles/build_containers/tasks/tag.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616

1717
- name: Ensure directories are present
1818
ansible.builtin.file:
19-
path: "{{ cifmw_build_containers_basedir }}/{{ item }}"
19+
path: "{{ cifmw_build_containers_basedir }}/{{ created_dir }}"
2020
state: directory
2121
mode: "0755"
2222
loop:
2323
- tmp
2424
- artifacts
2525
- logs
26+
loop_control:
27+
loop_var: created_dir
2628

2729
- name: Make sure authfile exists
2830
when:
@@ -56,17 +58,15 @@
5658
ansible.builtin.shell:
5759
cmd: >-
5860
set -o pipefail;
59-
cat {{ cifmw_build_containers_basedir }}/logs/containers-built.log |
60-
grep {{ cifmw_build_containers_container_name_prefix }} |
61+
grep {{ cifmw_build_containers_container_name_prefix }} {{ cifmw_build_containers_basedir }}/logs/containers-built.log |
6162
awk '{ print $1 }'
6263
register: built_images_from_file
6364

6465
- name: Get the hash tag from the log file
6566
ansible.builtin.shell:
6667
cmd: >-
6768
set -o pipefail;
68-
cat {{ cifmw_build_containers_basedir }}/logs/containers-built.log |
69-
grep {{ cifmw_build_containers_container_name_prefix }} |
69+
grep {{ cifmw_build_containers_container_name_prefix }} {{ cifmw_build_containers_basedir }}/logs/containers-built.log |
7070
awk '{ print $2 }' | head -n 1
7171
register: images_tag_from_file
7272

@@ -81,23 +81,28 @@
8181

8282
- name: Pull images returned in built_images
8383
containers.podman.podman_image:
84-
name: "{{ item }}"
84+
name: "{{ loop_img_name }}"
8585
tag: "{{ images_tag }}"
8686
loop: "{{ built_images }}"
87+
loop_control:
88+
loop_var: loop_img_name
8789

8890
- name: Retag the images with new tag
8991
containers.podman.podman_tag:
90-
image: "{{ item }}:{{ images_tag }}"
92+
image: "{{ loop_img_name }}:{{ images_tag }}"
9193
target_names:
92-
- "{{ item }}:{{ cifmw_build_containers_tag_string }}"
94+
- "{{ loop_img_name }}:{{ cifmw_build_containers_tag_string | trim }}"
9395
loop: "{{ built_images }}"
96+
loop_control:
97+
loop_var: loop_img_name
9498

9599
- name: Push images to registry with new tag
96100
containers.podman.podman_image:
97-
name: "{{ item }}"
98-
push_args:
99-
dest: "{{ cifmw_build_containers_push_registry }}/{{ cifmw_build_containers_registry_namespace }}"
100-
tag: "{{ cifmw_build_containers_tag_string }}"
101-
pull: false
101+
name: "{{ loop_img_name }}"
102+
tag: "{{ cifmw_build_containers_tag_string | trim }}"
102103
push: true
104+
push_args:
105+
dest: "{{ cifmw_build_containers_push_registry }}/{{ cifmw_build_containers_registry_namespace }}/{{ loop_img_name | basename }}:{{ cifmw_build_containers_tag_string | trim }}"
103106
loop: "{{ built_images }}"
107+
loop_control:
108+
loop_var: loop_img_name

0 commit comments

Comments
 (0)