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

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

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/ サブディレクトリーを含めます。
注記

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

これで、CLI を使用して Automation Hub をプライマリーサーバーとして設定できました。次に、サポートされているコレクションのダウンロードとインストールに進むことができます。

関連情報

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