Automation hub 入门

Red Hat Ansible Automation Platform 2.1

将 Red Hat Automation Hub 配置为您的用于 Ansible 集合内容的默认服务器

Red Hat Customer Content Services

摘要

本指南指导您执行使用 Red Hat Automation Hub 作为认证 Ansible 集合内容的默认源所需的初始步骤。
提供反馈:
如果您对本文档有任何改进建议,或发现错误,请联系技术支持 https://access.redhat.com,使用 Docs组件在 Ansible Automation PlatformJIRA 项目中创建一个问题。

前言

Red Hat Ansible Automation Hub 为红帽订阅的用户提供了一个途径,以便快速找到并使用红帽及我们的技术合作伙伴支持的内容,以便为最需要的环境提供额外的保证。

Ansible Galaxy 客户端 ansible-galaxy,从命令行管理角色和集合。为确保 ansible-galaxy 客户端尽可能使用经过认证的受支持的 Ansible 集合,您应该更新 ansible.cfg 文件,以使用 Red Hat Automation Hub 作为 Ansible 集合的主要来源。

本指南指导您执行将 ansible.cfg 文件配置为使用 Red Hat Automation Hub 作为认证 Ansible 集合内容的默认源所需的步骤。

使开源包含更多

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。我们从这四个术语开始:master、slave、黑名单和白名单。由于此项工作十分艰巨,这些更改将在即将推出的几个发行版本中逐步实施。有关更多详情,请参阅我们的首席技术官 Chris Wright 提供的消息

第 1 章 创建 Red Hat Automation hub API 令牌

在通过上传或下载集合与 Automation Hub 交互前,您需要创建 API 令牌。Automation Hub API 令牌将您的 ansible-galaxy 客户端与 Red Hat Automation hub 服务器进行身份验证。

您可以使用自动化中心令牌 管理创建 API 令牌

先决条件

  • Red Hat Ansible Automation Platform 的有效订阅凭证。

流程

  1. 访问 https://cloud.redhat.com/ansible/automation-hub/token/
  2. 单击 Load Token
  3. copy 图标将 API 令牌复制到剪贴板。
  4. 将 API 令牌粘贴到文件中,并存储在安全位置。
重要

API 令牌是用于保护内容的 secret 令牌。将 API 令牌存储在安全位置。

API 令牌现在可以将自动化中心配置为默认集合服务器,或使用 ansible-galaxy 命令行工具上传集合。

1.1. 保持离线令牌处于活跃状态

当应用程序需要代表用户执行操作时,即使用户离线,则保持离线令牌处于活跃状态时很有用。例如,常规数据备份。

离线令牌在 30 天不活动后过期。您可以通过刷新离线令牌来保持离线令牌。

注意

离线令牌过期后,您必须请求一个新令牌。

定期运行以下命令防止您的令牌过期:

curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id="cloud-services" -d refresh_token="{{ user_token }}" --fail --silent --show-error --output /dev/null

第 2 章 将 Red Hat Automation Hub 配置为内容的主要来源

您可以将 Red Hat Automation Hub 定义为 ansible.cfg 配置文件的默认内容源。

先决条件

  • 获取 Automation Hub 服务器的 API 令牌。如需更多信息,请参阅创建自动 Hub API 令牌。

流程

  1. [galaxy] 部分添加 server_list 选项,并提供一个或多个服务器名称。
  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 示例演示了如何按优先顺序配置多个服务器,自动化中心配置为您的主源,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
在 Galaxy 服务器 URL 中包含 /api/galaxy/ 子目录。
3
在自动化中心服务器 URL 中包含 /api/galaxy/ 子目录。

现在,已将 Automation Hub 配置为您的默认服务器,并可开始下载并安装支持的集合。

有关服务器列表配置选项以及使用 Ansible Galaxy 作为 Ansible 内容源的更多信息,请参阅 Ansible Galaxy 用户指南

法律通告

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.