[Cherry-pick 202503] ansible: support pulling ceos_image from docker registry#1082
Open
wangxinbot wants to merge 1 commit intoAzure:202503from
Open
[Cherry-pick 202503] ansible: support pulling ceos_image from docker registry#1082wangxinbot wants to merge 1 commit intoAzure:202503from
wangxinbot wants to merge 1 commit intoAzure:202503from
Conversation
What is the motivation for this PR? In environments that enforce registry-only container image policies (e.g. Microsoft requiring all images to originate from ACR or MCR), the previous approach of building ceos_image locally or re-tagging a pulled image with a local name would trigger security alerts. This PR allows ceos_image to be sourced directly from a user-configured registry, so containers always reference the registry-prefixed image name and no locally-built alias is created. How did you do it? Three files are changed: ansible/group_vars/vm_host/ceos.yml Added three commented-out placeholder variables: ceos_registry, ceos_registry_username, ceos_registry_password. When ceos_registry is uncommented and set, the new registry logic is activated. Credentials are optional and only needed for authenticated registries. ansible/roles/vm_set/tasks/add_ceos_list.yml When ceos_registry is defined, check whether <registry>/<ceos_image> is already cached locally (a prior pull). If found, it is used directly — no docker tag is performed, so no local alias is created. If not cached and ceos_registry is defined, optionally log in (only when credentials are provided) and docker pull the image. Only falls back to the existing download-ceos_image_orig-and-build path when registry is not configured or the pull fails. ceos_image_found logic is registry-aware: when ceos_registry is defined, a plain local ceos_image does not count as "found", ensuring the registry path is always taken. ansible/roles/eos/tasks/ceos.yml and ceos_ensure_reachable.yml After loading group_vars/vm_host/ceos.yml, a docker_image_info check determines whether the registry image is available locally. ceos_effective_image is set to <registry>/<ceos_image> when the registry image is present, or plain ceos_image otherwise. All docker_container tasks use ceos_effective_image instead of ceos_image, so containers always reference the registry image in registry-enabled environments. How did you verify/test it? Tested "add-topo" by specifying ceos_registry. The ceos image from the registry is used successfully. Tested "add-topo" without specifying ceos_registry. The existing logic of using a local ceos image or preparing ceos image from ceos_image_orig works as expected. Signed-off-by: Xin Wang <[email protected]> Co-authored-by: Copilot <[email protected]>
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of sonic-net/sonic-mgmt#22794 to 202503 branch.
Original PR: sonic-net/sonic-mgmt#22794
Conflicts resolved in ansible/roles/vm_set/tasks/add_ceos_list.yml.