3.5. カスタム実行環境定義の作成
Ansible Builder をインストールしたら、次の手順を使用してカスタム実行環境を作成します。
手順
カスタム実行環境のビルドアーティファクトを保存するディレクトリーを作成します。以下の手順で作成する新しいファイルは、このディレクトリーの下に作成されます。
$ mkdir $HOME/custom-ee $HOME/custom-ee/files $ cd $HOME/custom-ee/カスタム実行環境の要件を定義する
execution-environment.ymlファイルを作成します。注記実行環境定義フォーマットのバージョン 3 が必要です。続行する前に、
execution-environment.ymlファイルにversion: 3が明示的に含まれていることを確認してください。- Private Automation Hub で利用可能な最小実行環境を指すように、ベースイメージをオーバーライドします。
ビルドプロセスで使用する非接続のコンテンツソースを指すために必要な、追加のビルドファイルを定義します。作成したカスタム実行環境設定ファイル
(execution-environment.yml) は、以下の例のようになるはずです。version: 3 images: base_image: name: private-hub.example.com/ee-minimal-rhel8:latest dependencies: python: requirements.txt galaxy: requirements.yml additional_build_files: - src: files/ansible.cfg dest: configs - src: files/pip.conf dest: configs - src: files/hub-ca.crt dest: configs # uncomment if custom RPM repositories are required #- src: files/custom.repo # dest: configs additional_build_steps: prepend_base: # copy a custom pip.conf to override the location of the PyPI content - ADD _build/configs/pip.conf /etc/pip.conf # remove the default UBI repository definition - RUN rm -f /etc/yum.repos.d/ubi.repo # copy the hub CA certificate and update the trust store - ADD _build/configs/hub-ca.crt /etc/pki/ca-trust/source/anchors - RUN update-ca-trust # if needed, uncomment to add a custom RPM repository configuration #- ADD _build/configs/custom.repo /etc/yum.repos.d/custom.repo prepend_galaxy: - ADD _build/configs/ansible.cfg ~/.ansible.cfg ...
files/サブディレクトリーの下に、プライベート Automation Hub を指すansible.cfgファイルを作成します。$ cat files/ansible.cfg [galaxy] server_list = private_hub [galaxy_server.private_hub] url = /https://private-hub.example.com/api/galaxy/files/サブディレクトリーの下に、内部 PyPI ミラー (Web サーバーや Nexus のようなもの) を指すpip.confファイルを作成します。$ cat files/pip.conf [global] index-url = https://<pypi_mirror_fqdn>/ trusted-host = <pypi_mirror_fqdn>オプション:
bindep.txtファイルを使用してカスタム実行環境に RPM パッケージを追加する場合は、files/サブディレクトリーの下にcustom.repoファイルを作成し、切断された Satellite または RPM リポジトリーをホストする他の場所を指すようにします。この手順が必要な場合は、例のexecution-environment.ymlファイル内のcustom.repoファイルに対応する手順のコメントを解除してください。次の例は UBI リポジトリーの場合です。他のローカルリポジトリーもこのファイルに追加できます。ミラーコンテンツが Web サーバーのどこにあるかに応じて、URL パスの変更が必要な場合があります。
$ cat files/custom.repo [ubi-8-baseos] name = Red Hat Universal Base Image 8 (RPMs) - BaseOS baseurl = http://<ubi_mirror_fqdn>/repos/ubi-8-baseos enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release gpgcheck = 1 [ubi-8-appstream] name = Red Hat Universal Base Image 8 (RPMs) - AppStream baseurl = http://<ubi_mirror_fqdn>/repos/ubi-8-appstream enabled = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release gpgcheck = 1Private Automation Hub Web サーバー証明書の署名に使用される CA 証明書を追加します。Private Automation Hub が、インストーラーによって提供される自己署名証明書を使用する場合は、以下の手順を行います。
-
プライベート Automation Hub からファイル
/etc/pulp/certs/pulp_webserver.crtをコピーし、hub-ca.crtという名前を付けます。 -
hub-ca.crtファイルをfiles/サブディレクトリーに追加してください。
-
プライベート Automation Hub からファイル
Private Automation Hub が、認証局によって署名されたユーザー提供の証明書を使用する場合は、以下の手順を行います。
-
その CA 証明書のコピーを作成し、
hub-ca.crtという名前を付けてください。 -
hub-ca.crtファイルをfiles/サブディレクトリーに追加します。
-
その CA 証明書のコピーを作成し、
上記の手順を完了したら、カスタム実行環境イメージに必要な内容を含む、Python の
requirements.txtファイルと Ansible コレクションのrequirements.ymlファイルを作成します。注記必要なコレクションはすべて、Private Automation Hub に事前にアップロードする必要があります。
custom-ee/ディレクトリーには、以下のファイルが存在する必要があります。bindep.txtとfiles/custom.repoはオプションです。$ cd $HOME/custom-ee $ tree . . ├── bindep.txt ├── execution-environment.yml ├── files │ ├── ansible.cfg │ ├── custom.repo │ ├── hub-ca.crt │ └── pip.conf ├── requirements.txt └── requirements.yml 1 directory, 8 files