第2章 コンテンツの主なソースとして Red Hat Automation Hub を設定

Ansible Certified Content Collections にアクセスするための、Red Hat Automation Hub を主要なコンテンツソースとして設定します。コマンドラインインターフェイス(CLI)または Web コンソールで Automation Hub を設定できます。

2.1. CLI を使用したコンテンツのプライマリーソースとしての Red Hat Automation Hub の設定

CLI を使用して、Red Hat Automation Hub を主要なコンテンツソースとして設定します。Automation Hub を設定するには、ansible.cfg 設定ファイルを変更する必要があります。Automation Hub を使用すると、認定済みのサポートされるコレクションにアクセスできます。

前提条件

Creating a new token revokes any previous tokens
generated for Private Automation Hub. Ensure that you update any Controller or scripts that you created with the previous token.

手順

  1. [galaxy] セクション配下に server_list オプションを追加し、1 つ以上のサーバー名を指定します。
  2. 各サーバー名に新しいセクションを作成します。

    [galaxy_server._<server_name>_]
  3. 各サーバー名に url オプションを設定します。サーバー URL に api/galaxy/ サブディレクトリーを含める必要があります。

    https://<server_fully_qualified_domain_name>/api/galaxy/
  4. 必要に応じて、auth_url オプションを設定します。コミュニティーの Ansible Galaxy には auth_url が必要ありません。
  5. Automation Hub サーバーの API トークンを設定します。

以下の ansible.cfg 設定ファイルの例は、優先順位の高い順に複数のサーバーを設定する方法を示しています。Automation Hub はプライマリーソースとして設定され、Ansible Galaxy サーバーがセカンダリーソースとして設定されています。

ansible.cfg

[galaxy]
server_list = automation_hub, my_org_hub

[galaxy_server.automation_hub]
url=https://cloud.redhat.com/api/automation-hub/api/galaxy/ 1 2
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token

token=my_ah_token

[galaxy_server.my_org_hub]
url=https://automation.my_org/api/galaxy/ 3
username=my_user
password=my_pass

1
末尾のスラッシュを含める / サーバー URL の後。
2
Ansible Galaxy サーバーの URL に /api/galaxy/ サブディレクトリーを含めます。
3
Automation Hub サーバーの URL に /api/galaxy/ サブディレクトリーを含めます。
注記

すべての API URL は末尾のスラッシュで終了する必要があります。 / 301 リダイレクトの受信を防ぐために。

これで、CLI を使用して Automation Hub をプライマリーサーバーとして設定し、サポートされるコレクションのダウンロードおよびインストールを続行できるようになりました。

関連情報

サーバーリストの設定オプションおよび Ansible Galaxy を Ansible コンテンツソースとして使用する方法の詳細は、Ansible Galaxy ユーザーガイド を参照してください。