在自动 Hub 中管理红帽认证的集合和 Ansible Galaxy 集合

Red Hat Ansible Automation Platform 2.2

配置 Automation Hub,为用户提供红帽认证的集合内容和 Ansible Galaxy 集合的内容。

Red Hat Customer Content Services

摘要

提供反馈:
如果您对本文档有任何改进建议,或发现错误,请联系技术支持 https://access.redhat.com,使用 Docs组件在 Ansible Automation PlatformJIRA 项目中创建一个问题。

前言

您可以同步 Automation Hub 来使用通过 Ansible Automation Platform 订阅提供的红帽认证的集合(Certified Collections),或使用通过 Ansible Galaxy 提供的社区集合。

您的机构可从 console.redhat.com 上托管的自动 hub 服务中的所有红帽认证内容中访问并策展到一组特定的集合。

您还可以配置私有自动化中心以签名和发布定制的 Ansible 内容集合,以满足您机构的独特需求。

使开源包含更多

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

第 1 章 在 Automation Hub 中管理红帽认证的集合同步列表

您可以通过创建同步列表,使用 Automation Hub 向用户分发相关的红帽认证的集合内容。

1.1. 关于红帽认证的集合同步列表

同步列表(synclist)是红帽认证集合的策展组,由您的机构管理员创建并同步到本地 Automation Hub。使用同步列表,可以管理您需要的内容,并排除不必要的集合内容。您可以根据 console.redhat.com 所提供的红帽认证集合的一部分来设计并管理您的同步列表。

每个同步列表都有其自身唯一的存储库 URL,您可以使用它指定为 Automation Hub 中内容的远程源,并使用 API 令牌对其进行安全访问。

1.2. 创建红帽认证的集合的同步列表

您可以在 console.redhat.com 上的 Automation Hub 中创建一个策展的红帽认证集合同步列表。您的同步列表存储库位于 Automation HubRepo Management 下,每当您选择管理红帽认证的集合中的内容时,会进行更新。

默认情况下,您的初始机构同步列表中包含了所有红帽认证的集合。

前提条件

  • 有一个有效的 Ansible Automation Platform 订阅。
  • 具有 console.redhat.com 的机构管理员权限。
  • 确保以下域名是防火墙或代理的允许列表一部分,以便能成功连接并从自动化中心或 Galaxy 服务器下载集合:

    • galaxy.ansible.com
    • cloud.redhat.com
    • console.redhat.com
    • sso.redhat.com
  • 自动化中心资源存储在 Amazon Simple Storage 中。在允许列表中添加以下域名:

    • automation-hub-prd.s3.us-east-2.amazonaws.com
    • ansible-galaxy.s3.amazonaws.com
  • 在使用自签名证书或红帽域时,SSL 检查会被禁用。

流程

  1. 登录到 console.redhat.com。
  2. 进入 Automation HubCollections
  3. 在每个集合中使用切换开关来决定是否将其从同步列表中排除。

完成同步列表管理集合后,您可以进入 Automation HubRepo Management 以将远程存储库同步启动到本地 Automation Hub。如果已经配置了远程存储库,您可以手动将红帽认证的集合同步到本地 Automation Hub,以更为本地用户提供可用的集合内容。

第 2 章 配置 Automation Hub 远程存储库,以从红帽认证的集合和 Ansible Galaxy 集合中同步内容

您可以将本地 Automation Hub 配置为与 console.redhat.com 上机构存储库中托管的红帽认证集合进行同步,或与您在 Ansible Galaxy 中选择的集合同步。

2.1. 关于远程软件仓库

您可以通过配置远程存储库,将本地 Automation Hub 配置为与 console.redhat.com 上机构存储库中托管的红帽认证集合进行同步,并与您选择的 Ansible Galaxy 中的集合进行同步。

位于 Repo ManagementRemote 的每个远程存储库都针对 communityrh-certified 提供了关于存储库最新更新以及最新同步的时间信息。您可以使用 Repo ManagementRemote 页面中包含的 EditSync 功能随时向自动化中心添加新内容。

2.2. 检索您的红帽认证集合同步 URL 和 API 令牌。

您可以将您的机构从 console.redhat.com 提供的红帽认证的集合同步到本地 Automation Hub。

前提条件

  • 具有 console.redhat.com 的机构管理员权限。

流程

  1. 以机构管理员身份登录到 console.redhat.com。
  2. 进入 Automation HubRepo Management
  3. 找到 Sync URL,点 Copy to clipboard 图标 ( Copy )。将 Sync URL 粘贴到配置 rh-certified remote 时要使用的文件中。
  4. More actions 图标 More 并点 Get token
  5. Token Management 页面上,点 Load token
  6. Copy to clipboard 复制 API 令牌。
  7. 将 API 令牌粘贴到文件中,并存储在安全位置。
重要

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

2.3. 配置 rh-certified 远程存储库并同步 Red Hat Ansible 认证的内容集合。

您可以编辑 rh-certent 的远程仓库,以便将托管在 cloud.redhat.com 中的 Automation Hub 的集合同步到本地 Automation Hub。默认情况下,您的本地 Automation Hub rh- certified 仓库包含 cloud.redhat.com 上整个红帽认证集合组的 URL。要只使用您的机构指定的集合,您必须包括一个唯一的 URL。

先决条件

  • 您有修改 Ansible 存储库内容的权限。如需了解更多有关权限的信息,请参阅 Automation Hub 中的管理用户访问权限
  • 您已从 console.redhat.com 上的自动化中心托管服务中检索 Sync URL 和 API Token。
  • 您已配置了端口 443 的访问权限。这是同步认证集合所必需的。如需更多信息,请参阅 Red Hat Ansible Automation Platform 规划指南中的网络端口和协议一章中的自动化中心表。

流程

  1. 登录到您的本地自动化中心。
  2. 进入 Repo Management
  3. Remotes 选项卡。
  4. rh-certified 远程中,点 More actions 并点 Edit
  5. 在相关界面中,粘贴您从 cloud.redhat.com 获取的 Sync URL 和 Token。
  6. 点击 Save

界面关闭并返回到 Repo Management 页面。现在,您可以在 console.redhat.com 上的机构同步列表和私有自动化中心之间同步集合。

+ .点 Sync 来同步集合。

Sync status 通知将更新为您在红帽认证的集合同步完成后通知您。

验证

您可以通过从集合内容下拉列表中选择 Red Hat Certified,确认您的集合内容已成功同步。

2.4. 配置社区远程存储库并同步 Ansible Galaxy 集合。

您可以编辑 community 远程仓库,将所选的集合从 Ansible Galaxy 同步到本地 Automation Hub。默认情况下,您的本地自动化中心 community 仓库定向到 https://galaxy.ansible.com/api/

先决条件

  • 您有修改 Ansible 存储库内容的权限。如需了解更多有关权限的信息,请参阅 Automation Hub 中的管理用户访问权限
  • 您有一个 requirements.yml 文件,用于标识要从 Ansible Galaxy 同步的集合。请参见以下示例。

Requirements.yml 示例

collections:
  # Install a collection from {Galaxy}.
  - name: community.aws
    version: 5.2.0
    source: https://galaxy.ansible.com

流程

  1. 登录到您的本地自动化中心。
  2. 进入 Repo Management
  3. Remotes 选项卡。
  4. Community 远程中,点 More Actions 图标 More 并点 Edit
  5. 在相应的界面中,点 Browse 并在本地机器上找到 requirements.yml 文件。
  6. 点击 Save

界面关闭并返回到 Repo Management 页面。现在,您可以将 requirements.yml 文件中标识的集合从 Ansible Galaxy 同步到本地自动化中心。

  1. Sync 以同步来自 Ansible Galaxy 和 Automation Hub 的集合。

Sync status 通知将会更新,以告知您 Automation Hub 与 Ansible Galaxy 集合的同步是否已完成或失败。

验证

您可以从集合内容下拉列表中选择 Community 来确认同步成功。

第 3 章 在私有自动化中心中的集合和内容签名

作为机构的自动化管理员,您可以配置私有自动化中心,以根据机构中的不同组签名和发布 Ansible 内容集合。

为提高安全性,自动化创建者可以配置 Ansible-Galaxy CLI 以验证这些集合,确保在上传到自动化中心后不会更改它们。

3.1. 在私有自动化 hub 中配置内容签名

要成功签名并发布 Ansible 认证的内容集合,您必须配置私有自动化中心进行签名。

前提条件

  • 您的 TIPC 密钥对已安全设置并管理您的机构。
  • 您的公钥/私钥对有权在私有自动化中心上配置内容签名。

流程

  1. 创建仅接受文件名的签名脚本。

    注意

    此脚本将充当签名服务,且必须使用通过 PULP_SIGNING_KEY_FINGERPRINT 环境变量指定的密钥为该文件生成 ascii-armored 分离的 gpg 签名。

    然后,该脚本会输出一个 JSON 结构,其格式如下:

    {"file": "filename", "signature": "filename.asc"}

    所有文件名都是当前工作目录中的相对路径。对于分离的签名,文件名必须保持相同,如下所示。

    以下示例显示了为内容生成签名的脚本:

    #!/usr/bin/env bash
    
    FILE_PATH=$1
    SIGNATURE_PATH="$1.asc"
    
    ADMIN_ID="$PULP_SIGNING_KEY_FINGERPRINT"
    PASSWORD="password"
    
    # Create a detached signature
    gpg --quiet --batch --pinentry-mode loopback --yes --passphrase \
       $PASSWORD --homedir ~/.gnupg/ --detach-sign --default-key $ADMIN_ID \
       --armor --output $SIGNATURE_PATH $FILE_PATH
    
    # Check the exit status
    STATUS=$?
    if [ $STATUS -eq 0 ]; then
       echo {\"file\": \"$FILE_PATH\", \"signature\": \"$SIGNATURE_PATH\"}
    else
       exit $STATUS
    fi

    部署私有自动化中心后,向 Ansible Automation Platform 集群启用签名后,新的 UI 会在与集合交互时显示。

  2. 查看 Ansible Automation Platform 安装程序清单文件,了解以 automationhub framework 开头的选项。

    [all:vars]
    .
    .
    .
    automationhub_create_default_collection_signing_service = True
    automationhub_auto_sign_collections = True
    automationhub_require_content_approval = True
    automationhub_collection_signing_service_key = /abs/path/to/galaxy_signing_service.gpg
    automationhub_collection_signing_service_script = /abs/path/to/collection_signing.sh

    两个新密钥(automationhub_auto_sign_collectionsautomationhub_require_content_approval)表示必须签名集合,并在上传到私有自动化中心后需要批准。

3.2. 在私有自动化中心中使用内容签名服务

在对私有自动化中心配置了内容签名后,您可以手动为新集合签名,或者将现有签名替换为新的签名,以便希望下载特定集合的用户保证集合是面向它们且在认证后没有修改。

私有自动化中心的内容签名为以下情况提供了解决方案:

  • 您的系统没有配置自动签名,您必须使用手动签名过程来签署集合。
  • 自动配置的集合中的当前签名已损坏,且必须使用新的签名替换。
  • 之前签名的内容需要额外的签名。
  • 您希望在集合中轮转签名。

流程

  1. 在自动化中心 UI 中登录到您的私有自动化中心实例。
  2. 在左侧导航中,点 CollectionsApproval。Approval dashboard 带有集合列表会显示。
  3. 对您要签名的每个集合点 Sign and approve
  4. 验证您手动签名和批准的集合是否显示在 Collections 选项卡中。

3.3. 配置 Ansible-Galaxy CLI 以验证集合

您可以配置 Ansible-Galaxy CLI 来验证集合。这样可确保您下载的集合可由您的机构批准,在上传到自动化中心后没有更改。

如果某个集合由自动化中心签名,服务器会提供 ASCII armored,GPG-detached 签名在使用它验证集合的内容前验证 MANIFEST.json 的真实性。您必须通过为 ansible-galaxy 配置密钥环或使用 --keyring 选项提供路径来选择签名验证。

前提条件

  • 签名的集合在自动化中心中可用于验证签名。
  • 认证的集合可以由机构中的批准角色签名。
  • 验证的公钥已添加到本地系统密钥环中。

流程

  1. 要将公钥导入到用于 ansible-galaxy 的非默认密钥环中,请运行以下命令:

    gpg --import --no-default-keyring --keyring ~/.ansible/pubring.kbx my-public-key.asc
    注意

    除了自动化中心提供的任何签名外,也可在要求文件和命令行中提供签名源。签名源应当是 URI。

  2. 使用 --signature 选项验证 CLI 上提供的集合名称以及其他签名。

    ansible-galaxy collection install namespace.collection
    --signature https://examplehost.com/detached_signature.asc
    --signature file:///path/to/local/detached_signature.asc --keyring ~/.ansible/pubring.kbx

    您可以多次使用这个选项提供多个签名。

  3. 确认要求文件中的集合在集合的签名密钥后列出任何其他签名源,如下例所示。

    # requirements.yml
    collections:
      - name: ns.coll
        version: 1.0.0
        signatures:
          - https://examplehost.com/detached_signature.asc
          - file:///path/to/local/detached_signature.asc
    
    ansible-galaxy collection verify -r requirements.yml --keyring ~/.ansible/pubring.kbx

    当您从自动化中心安装集合时,服务器提供的签名会与安装的集合一起保存,以验证集合的真实性。

  4. (可选)如果您需要在不查询 Ansible Galaxy 服务器的情况下再次验证集合的内部一致性,请使用 --off 命令行选项运行之前使用的相同命令

第 4 章 总结

完成所有前面的步骤后,您将拥有:

  • 为红帽认证的集合内容创建一个同步列表。
  • 将内容同步到本地自动化中心。
  • 指定 Ansible Galaxy 中的社区集合,以分发到您的用户。
  • 在私有自动化中心上配置的内容签名。
  • 为您的机构特定需求签名和批准的集合。
  • 配置 Ansible-Galaxy CLI,以便在为集合签名前验证集合。

用户现在可以从本地自动化中心查看和下载集合内容。

法律通告

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.