第 2 章 将 Red Hat Automation Hub 配置为内容的主要来源
将 Red Hat Automation Hub 配置为访问 Ansible 认证内容集合的主要内容源。您可以在命令行界面(CLI)或 Web 控制台中配置自动化中心。
2.1. 使用 CLI 将 Red Hat Automation Hub 配置为内容的主要源
使用 CLI 将 Red Hat Automation Hub 配置为您的内容主要来源。要配置自动化中心,您必须修改 ansible.cfg 配置文件。使用自动化中心,您可以访问经过认证且受支持的集合。
先决条件
- 您已获取 Automation Hub 服务器的 API 令牌。如需更多信息 ,请参阅创建 Red Hat Automation hub API 令牌。
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.
流程
-
在
[galaxy]部分下添加server_list选项,并提供一个或多个服务器名称。 为每个服务器名称创建一个新部分:
[galaxy_server._<server_name>_]
为每个服务器名称设置
url选项。您必须在服务器 URL 中包含api/galaxy/子目录:https://<server_fully_qualified_domain_name>/api/galaxy/-
可选:设置
auth_url选项。社区 Ansible Galaxy 不需要auth_url。 - 为 Automation Hub 服务器设置 API 令牌。
以下 ansible.cfg 配置文件示例演示了如何按优先顺序配置多个服务器,自动化中心配置为您的主源,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
注意
所有 API URL 必须以斜杠 / 结尾,以防止收到 301 重定向。
现在,您已使用 CLI 将 Automation Hub 配置为主服务器,并可继续下载并安装支持的集合。
其他资源
有关服务器列表配置选项以及使用 Ansible Galaxy 作为 Ansible 内容源的更多信息,请参阅 Ansible Galaxy 用户指南。