Skip to content

Commit

Permalink
Merge pull request #528 from redhatci/set_org_mirror_images
Browse files Browse the repository at this point in the history
[mirror_images] allow to set the image registry org
  • Loading branch information
manurodriguez authored Jan 24, 2025
2 parents acae402 + 4610b9d commit 01e91e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions roles/mirror_images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Mirrors images from one repository to another.
| mi_dst_authfile | undefined | No | An authfile with permissions to push the target images
| mi_options | undefined | No | skopeo options while copying the images
| mi_src_authfile | undefined | No | An authfile with permissions to pull the source images
| mi_dst_org | undefined | No | The organization target where to copy the images

## Requirements

Expand Down Expand Up @@ -47,4 +48,6 @@ Mirrors images from one repository to another.
mi_dst_authfile: /path/to/pullsecret-to-push-to-my-registry-local
mi_src_authfile: /path/to/pullsecret-to-pull-from-private-image
mi_options: "--preserve-digests"
mi_dst_org: "some/path"
```
The use of `mi_dst_org`: "some/path" will copy the new images into a new repository organization. For instance if the source image is quay.io/centos/centos:stream9, the destination will be my.registry.local:4443/some/path/centos:stream9
1 change: 1 addition & 0 deletions roles/mirror_images/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mi_dst_org: ""
7 changes: 5 additions & 2 deletions roles/mirror_images/tasks/mirror-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
- name: "Mirror image"
vars:
_image_tag: "{{ image | regex_search('(?<=sha256)(.{12})') | default('', True) }}"
_image_name: "{{ '/'.join(image.split('@')[0].split('/')[1:]) }}"
_tgt_image_location: "{{ mi_registry }}/{{ _image_name }}{%- if _image_tag | length %}{{ _image_tag }}{% endif %}"
_image_name: "{{ '/'.join(image.split('@')[0].split('/')[-1:]) }}"
_image_org: "{{ '/'.join(image.split('@')[0].split('/')[1:-1]) }}"
_image_org_path: "{{ (mi_dst_org | length) | ternary(mi_dst_org, _image_org) }}"
_image_img_path: "{{ _image_name }}{%- if _image_tag | length %}{{ _image_tag }}{% endif %}"
_tgt_image_location: "{{ mi_registry }}/{{ _image_org_path }}/{{ _image_img_path }}"
block:
- name: "Mirror image"
ansible.builtin.command:
Expand Down

0 comments on commit 01e91e8

Please sign in to comment.