使用环境变量构建 EE 以进行 Galaxy 配置
Ansible Builder 版本 3 架构允许用户执行复杂场景,例如指定自定义 Galaxy 配置。您可以使用此方法将敏感信息(例如身份验证令牌)传递到 EE 构建中,而不会将其泄漏到最终的 EE 镜像中。
在下面的示例中,我们将了解
使用 Galaxy Server 环境变量
---
version: 3
images:
base_image:
# Needs login
name: registry.redhat.io/ansible-automation-platform-23/ee-minimal-rhel8:latest
dependencies:
# No need to specify ansible-core or ansible-runner dependencies
# because they are included in the base image.
# Collections to be installed using Galaxy
galaxy:
collections:
- ansible.utils
additional_build_steps:
prepend_galaxy:
# Environment variables used for Galaxy client configurations
- ENV ANSIBLE_GALAXY_SERVER_LIST=automation_hub
- ENV ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_URL=https://console.redhat.com/api/automation-hub/content/xxxxxxx-synclist/
- ENV ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_AUTH_URL=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
# define a custom build arg env passthru - we still also have to pass
# `--build-arg ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN` to get it to pick it up from the env
- ARG ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN
options:
package_manager_path: /usr/bin/microdnf # downstream images use non-standard package manager
您可以使用 ENV
指令提供诸如 ANSIBLE_GALAXY_SERVER_LIST
、ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_URL
和 ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_AUTH_URL
之类的环境变量。有关更多详细信息,请参阅 配置 Galaxy 客户端。
出于安全原因,我们不希望在此处存储敏感信息 ANSIBLE_GALAXY_SERVER_AUTOMATION_HUB_TOKEN。您可以使用 ARG 指令从用户那里接收敏感信息作为输入。–build-args 可用于在调用 ansible-builder 命令时提供此信息。
另请参阅
- 执行环境定义版本 3
有关 EE 定义版本 3 的详细文档