3.4. 정의 파일 빌드
Ansible Builder를 사용하여 실행 환경을 만들 수 있습니다. 새 실행 환경을 빌드하려면 컬렉션, Python 요구 사항, 시스템 수준 패키지와 같은 실행 환경에 포함할 콘텐츠를 지정하는 정의가 포함됩니다.
Ansible Builder를 설치한 후 Ansible Builder에서 자동화 실행 환경 이미지를 생성하는 데 사용하는 정의 파일을 생성할 수 있습니다. Ansible Builder는 정의 파일을 읽고 검증한 다음 을 생성한 다음, 마지막으로 컨테이너 파일을 Podman에 전달하여 자동화 실행 환경 이미지를 패키지하고 자동화 실행 환경 이미지를 생성하여 자동화 실행 환경 이미지를 만듭니다. 생성하는 정의 파일은 Containerfile YAML 형식이어야 하며 .yaml 또는 . yml 확장자가 .yml 이고 다른 섹션이 포함되어 있어야 합니다. 기본 정의 파일 이름은 제공되지 않는 경우 execution-environment.yml 입니다. 정의 파일의 부분에 대한 자세한 내용은 정의 파일 콘텐츠 분리를 참조하십시오.
다음은 버전 3 정의 파일의 예입니다. 각 정의 파일은 사용하는 Ansible Builder 기능 세트의 주요 버전 번호를 지정해야 합니다. 지정하지 않는 경우 Ansible Builder는 기본적으로 버전 1로 설정되므로 대부분의 새로운 기능과 정의 키워드를 사용할 수 없습니다.
version: 3
build_arg_defaults:
ANSIBLE_GALAXY_CLI_COLLECTION_OPTS: '--pre'
dependencies:
galaxy: requirements.yml
python:
- six
- psutil
system: bindep.txt
images:
base_image:
name: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest
# Custom package manager path for the RHEL based images
options:
package_manager_path: /usr/bin/microdnf
additional_build_steps:
prepend_base:
- RUN echo This is a prepend base command!
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
prepend_final: |
RUN whoami
RUN cat /etc/os-release
append_final:
- RUN echo This is a post-install command!
- RUN ls -la /etc
- 빌드 인수의 기본값을 나열합니다.
- 다양한 요구 사항 파일의 위치를 지정합니다.
- 사용할 기본 이미지를 지정합니다. Red Hat 지원은 redhat.registry.io 기본 이미지에만 제공됩니다.
- 빌더 런타임 기능에 영향을 줄 수 있는 옵션을 지정합니다.
- 추가 사용자 정의 빌드 단계를 위한 명령입니다.