はじめに
ansbile-galaxy
コマンドは role や collection のインストールなどを行います。
デフォルトでは、Ansible Galaxyを参照します。
設定を変更することで、Automation Hub (レッドハット社提供の配布サービス) に変更できます。
ansible.tower
collection のように、Ansible Galaxy にはなくAutomation Hub にあるものをインストールする場合は、設定を変更する必要があります。
この記事では手順をご紹介します。
- 環境
- Ansible 2.9.15
トークンの取得
ansbile-galaxy
コマンドで Automation Hub を参照するにはトークンが必要です。以下の手順でトークンを取得します。
Automation Hub にログインし、左メニューの Connect to Hub
をクリックします。
Load Token
ボタンをクリックし、表示されたトークンを控えておきます。
ansible-galaxy
コマンドの設定
続いて、ansible-galaxy
コマンド側の設定です。
Ansible 公式ドキュメントの Downloading a collection from Automation Hub
にある通り、ansible.cfg
に以下の設定を行います。
[galaxy] server_list = automation_hub [galaxy_server.automation_hub] url=https://cloud.redhat.com/api/automation-hub/ auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token token=先程取得したトークンを指定
設定は以上です。
確認
確認として、Automation Hub から入手できる ansible.tower
collection をインストールします。
# ansible-galaxy collection install ansible.tower Process install dependency map Starting collection install process Installing 'ansible.tower:3.8.0' to '/root/.ansible/collections/ansible_collections/ansible/tower'
無事にインストールできました。
なお、Ansible Galaxy を参照する設定のまま ansible.tower
collection をインストールしようとすると、見つからないので以下のエラーが発生します。
# ansible-galaxy collection install ansible.towerProcess install dependency map ERROR! Failed to find collection ansible.tower:*