4.12. ansible-builder RPM のインストール

手順

  1. RHEL システムで、ansible-builder RPM をインストールします。これは、いくつかの方法で実行できます。

    1. 非接続ネットワーク上の Satellite で RHEL ボックスをサブスクライブします。
    2. Ansible Automation Platform サブスクリプションをアタッチし、AAP リポジトリーを有効にします。
    3. ansible-builder RPM をインストールします。

      注記

      基礎となるビルドホストが登録されている場合、EE イメージは Satellite から RHEL コンテンツを利用できるため、Satellite が存在する場合はこれが推奨されます。

  2. AAP セットアップバンドルをアーカイブから展開します。
  3. 含まれているコンテンツから ansible-builder RPM とその依存関係をインストールします。

    $ tar -xzvf ansible-automation-platform-setup-bundle-2.3-1.2.tar.gz
    $ cd ansible-automation-platform-setup-bundle-2.3-1.2/bundle/el8/repos/
    $ sudo yum install ansible-builder-1.2.0-1.el9ap.noarch.rpm
    python38-requirements-parser-0.2.0-4.el9ap.noarch.rpm
  4. カスタム EE ビルドアーティファクト用のディレクトリーを作成します。

    $ mkdir custom-ee
    $ cd custom-ee/
  5. https://ansible-builder.readthedocs.io/en/stable/definition/ のドキュメントに従って、カスタム EE の要件を定義する execution-environment.yml ファイルを作成します。EE_BASE_IMAGE 変数および EE_BUILDER_IMAGE 変数をオーバーライドして、Private Automation Hub で使用可能な EE を指すようにします。

    $ cat execution-environment.yml
    ---
    version: 1
    build_arg_defaults:
      EE_BASE_IMAGE: '<hub_fqdn>/ee-supported-rhel8:latest'
      EE_BUILDER_IMAGE: '<hub_fqdn>/ansible-builder-rhel8:latest'
    
    dependencies:
      python: requirements.txt
      galaxy: requirements.yml
  6. Private Automation Hub を指し、アップロードを許可する認証情報 (管理者ユーザートークンなど) を含む ansible.cfg ファイルを作成します。

    $ cat ansible.cfg
    [galaxy]
    server_list = private_hub
    
    [galaxy_server.private_hub]
    url=https://<hub_fqdn>/api/galaxy/
    token=<admin_token>
  7. 非接続 UBI リポジトリーミラーを指す ubi.repo ファイルを作成します (UBI コンテンツがそこにホストされている場合、これは Satellite である可能性があります)。

    これは、UBI リポジトリーをミラーリングするために reposync が使用された出力例です。

    $ cat ubi.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 = 1
  8. Private Automation Hub Web サーバー証明書の署名に使用される CA 証明書を追加します。

    1. 自己署名証明書 (インストーラーのデフォルト) の場合は、Private Automation Hub からファイル /etc/pulp/certs/root.crt のコピーを作成し、hub-root.crt という名前を付けます。
    2. Private Automation Hub Web サーバー証明書の要求と署名に内部認証局が使用された場合は、その CA 証明書のコピーを hub-root.crt という名前で作成します。
  9. カスタム EE イメージに必要なコンテンツを含む python の requirements.txt と ansible コレクションの requirements.yml を作成します。必要なコレクションはすべて、Private Automation Hub にアップロードされている必要があることに注意してください。
  10. ansible-builder を使用して、EE イメージのビルドに使用されるコンテキストディレクトリーを作成します。

    $ ansible-builder create
    Complete! The build context can be found at: /home/cloud-user/custom-ee/context
    $ ls -1F
    ansible.cfg
    context/
    execution-environment.yml
    hub-root.crt
    pip.conf
    requirements.txt
    requirements.yml
    ubi.repo
  11. インターネット向けのデフォルトをオーバーライドするために使用されるファイルをコンテキストディレクトリーにコピーします。

    $ cp ansible.cfg hub-root.crt pip.conf ubi.repo context/
  12. ファイル context/Containerfile を編集し、次の変更を追加します。

    1. 最初の EE_BASE_IMAGE ビルドセクションで、ansible.cfg および hub-root.crt ファイルを追加し、update-ca-trust コマンドを実行します。
    2. EE_BUILDER_IMAGE ビルドセクションで、ubi.repo および pip.conf ファイルを追加します。
    3. 最後の EE_BASE_IMAGE ビルドセクションで、ubi.repo および pip.conf ファイルを追加します。

      $ cat context/Containerfile
      ARG EE_BASE_IMAGE=<hub_fqdn>/ee-supported-rhel8:latest
      ARG EE_BUILDER_IMAGE=<hub_fqdn>/ansible-builder-rhel8:latest
      
      FROM $EE_BASE_IMAGE as galaxy
      ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS=
      USER root
      
      ADD _build /build
      WORKDIR /build
      
      # this section added
      ADD ansible.cfg /etc/ansible/ansible.cfg
      ADD hub-root.crt /etc/pki/ca-trust/source/anchors/hub-root.crt
      RUN update-ca-trust
      # end additions
      RUN ansible-galaxy role install -r requirements.yml \
          --roles-path /usr/share/ansible/roles
      RUN ansible-galaxy collection install \
          $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml \
          --collections-path /usr/share/ansible/collections
      
      FROM $EE_BUILDER_IMAGE as builder
      
      COPY --from=galaxy /usr/share/ansible /usr/share/ansible
      
      ADD _build/requirements.txt requirements.txt
      RUN ansible-builder introspect --sanitize \
          --user-pip=requirements.txt \
          --write-bindep=/tmp/src/bindep.txt \
          --write-pip=/tmp/src/requirements.txt
      # this section added
      ADD ubi.repo /etc/yum.repos.d/ubi.repo
      ADD pip.conf /etc/pip.conf
      # end additions
      RUN assemble
      
      FROM $EE_BASE_IMAGE
      USER root
      
      COPY --from=galaxy /usr/share/ansible /usr/share/ansible
      # this section added
      ADD ubi.repo /etc/yum.repos.d/ubi.repo
      ADD pip.conf /etc/pip.conf
      # end additions
      
      COPY --from=builder /output/ /output/
      RUN /output/install-from-bindep && rm -rf /output/wheels
  13. podman コマンドを使用して、ローカル podman キャッシュに EE イメージを作成します。

    $ podman build -f context/Containerfile \
        -t <hub_fqdn>/custom-ee:latest
  14. カスタム EE イメージが正常にビルドされたら、それを Private Automation Hub にプッシュします。

    $ podman push <hub_fqdn>/custom-ee:latest

4.12.1. マイナー AAP リリース間のアップグレードワークフロー

AAP 2 のマイナーリリース間でアップグレードするには、この一般的なワークフローを使用します。

手順

  1. 最新の AAP 2 セットアップバンドルをダウンロードし、アーカイブから展開します。
  2. 既存インストールのバックアップを作成します。
  3. 既存のインストールインベントリーファイルを新しいセットアップバンドルディレクトリーにコピーします。
  4. ./setup.sh を実行して、インストールをアップグレードします。

たとえば、バージョン 2.2.0-7 から 2.3-1.2 にアップグレードする場合は、インストールを実行した最初のコントローラーノードに両方のセットアップバンドルがあることを確認します。

    $ ls -1F
ansible-automation-platform-setup-bundle-2.2.0-7/
ansible-automation-platform-setup-bundle-2.2.0-7.tar.gz
ansible-automation-platform-setup-bundle-2.3-1.2/
ansible-automation-platform-setup-bundle-2.3-1.2.tar.gz

2.2.0-7 インストールをバックアップします。

$ cd ansible-automation-platform-setup-bundle-2.2.0-7
$ sudo ./setup.sh -b
$ cd ..

2.2.0-7 インベントリーファイルを 2.3-1.2 バンドルディレクトリーにコピーします。

$ cd ansible-automation-platform-setup-bundle-2.2.0-7
$ cp inventory ../ansible-automation-platform-setup-bundle-2.3-1.2/
$ cd ..

setup.sh スクリプトを使用して、2.2.0-7 から 2.3-1.2 にアップグレードします。

$ cd ansible-automation-platform-setup-bundle-2.3-1.2
$ sudo ./setup.sh