Automation hub 入门

Red Hat Ansible Automation Platform 2.2

将 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 服务器进行身份验证。

您可以使用 Automation Hub Token 管理创建 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 令牌可用于将 Automation Hub 配置为默认集合服务器,或使用 ansible-galaxy 命令行工具上传集合。

第 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 配置文件。使用自动化中心,您可以访问经过认证的支持的集合。

先决条件

Creating a new token revokes any previous tokens
generated for {PrivateHubName}. Ensure that you update any Controller or scripts that you created with the previous token.

流程

  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 配置示例演示了如何按优先顺序配置多个服务器,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
在自动化中心服务器 URL 中包含 /api/galaxy/ 子目录。
注意

所有 API URL 必须以尾部斜杠 / 结尾,以防止收到 301 重定向。

现在,您已使用 CLI 将自动化中心配置为您的主服务器,并可继续下载并安装支持的集合。

其他资源

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

2.2. 使用 web 控制台 将 Red Hat Automation hub 配置为内容的主要源

使用 Web 控制台将 Red Hat Automation hub 配置为您的主要内容源。要配置自动化中心,您必须创建一个凭证并将其添加到机构的 Galaxy Credentials 字段中。使用自动化中心,您可以访问经过认证的支持的集合。

先决条件

Creating a new token revokes any previous tokens
generated for {PrivateHubName}. Ensure that you update any Controller or scripts that you created with the previous token.

流程

  1. 进入您的自动化控制器。
  2. 创建一个新凭据。

    1. Credentials 屏幕中点 Add
    2. Name 字段中输入新凭证的名称。
    3. 可选:输入描述信息,再输入或选择与凭证关联的机构名称。
    4. Organization 下,选择要对其使用凭据的机构。
    5. 选择 Ansible Galaxy/Automation Hub API Token 作为凭证类型。
    6. Type Details 下,输入在实现先决条件时创建的 Galaxy Server URL, Authentication Server URL, 和 API 令牌
    7. 点击 Save
  3. 从机构的 Galaxy Credentials 字段选择您创建的凭证。

    1. 进入 AccessOrganizations
    2. 选择您要添加 Galaxy 凭证的机构。
    3. Edit
    4. 在 Galaxy 凭证下,点搜索图标。
    5. 选择您为自动化中心创建的凭证,并将其放在列表的开头。
    6. 可选: 如果您有二级内容源,如 Ansible Galaxy,请在您为自动化中心创建的凭证后放置此凭证。
    7. Select
    8. 点击 Save

验证

若要验证凭据,选择项目并点 Refresh 图标来更新基于该凭据的现有源控制管理 (SCM) 项目。

  1. 进入到您的项目存储库。
  2. 选择一个使用 collections/requirements.yml 文件的项目。
  3. 点 refresh 图标 [refresh icon] 来更新项目。

如果项目的状态为 Successful,则代表凭据是有效的。

现在,您已使用 Web 控制台将自动化中心配置为您的主服务器,并可继续下载并安装支持的集合。

其他资源

  1. 有关服务器列表配置选项以及使用 Ansible Galaxy 作为 Ansible 内容源的更多信息,请参阅 Ansible Galaxy 用户指南
  2. 有关创建和使用凭据的更多信息,请参阅自动化控制器用户指南 v4.2.1 中的 凭据 部分。

法律通告

Copyright © 2024 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.