2.3. 定義ファイルの構築
Ansible Builder をインストールした後、Ansible Builder が自動化実行環境イメージを作成するために使用する定義ファイルを作成できます。Ansible Builder は、定義ファイルを読み取って検証してから Containerfile を作成し、最後にその Containerfile を Podman に渡して自動化実行環境イメージを作成します。続いて Podman は、自動化実行環境イメージをパッケージ化して作成します。作成する定義ファイルは yaml 形式であり、さまざまなセクションが含まれている必要があります。指定されていない場合のデフォルトの定義ファイル名は、execution-environment.yml です。定義ファイルの各部分の詳細は、定義ファイルの内容の内訳 を参照してください。
以下はバージョン 3 の定義ファイルの例です。各定義ファイルでは、使用する Ansible Builder 機能セットのメジャーバージョン番号を指定する必要があります。指定しない場合、Ansible Builder はデフォルトでバージョン 1 になり、ほとんどの新機能と定義キーワードが使用できなくなります。
例2.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