4.12. 安装 ansible-builder RPM


流程

  1. 在 RHEL 系统上,安装 ansible-builder RPM。这可以通过以下方法之一完成:

    1. 将 RHEL 框订阅到断开连接的网络上的 Satellite。
    2. 附加 Ansible Automation Platform 订阅并启用 Ansible Automation Platform 存储库。
    3. 安装 ansible-builder RPM。

      注意

      如果存在 Satellite,则首选,因为如果底层构建主机已注册了底层构建主机,则执行环境镜像可以使用 Satellite 中的 RHEL 内容。

  2. 解压缩 Ansible Automation Platform 安装捆绑包。
  3. 从包含的内容安装 ansible-builder RPM 及其依赖项:

    $ tar -xzvf ansible-automation-platform-setup-bundle-2.3-1.2.tar.gz
    $ cd ansible-automation-platform-setup-bundle-2.3-1.2/bundle/el8/repos/
    $ sudo yum install ansible-builder-1.2.0-1.el9ap.noarch.rpm
    python38-requirements-parser-0.2.0-4.el9ap.noarch.rpm
    Copy to Clipboard Toggle word wrap
  4. 为您的自定义 EE 构建工件创建一个目录。

    $ mkdir custom-ee
    $ cd custom-ee/
    Copy to Clipboard Toggle word wrap
  5. 按照 https://ansible-builder.readthedocs.io/en/stable/definition/ 的文档创建 execution-environment.yml 文件,该文件定义了自定义 EE 的要求。覆盖 EE_BASE_IMAGEEE_BUILDER_IMAGE 变量,以指向私有自动化中心中提供的 EE。

    $ cat execution-environment.yml
    ---
    version: 1
    build_arg_defaults:
      EE_BASE_IMAGE: '<hub_fqdn>/ee-supported-rhel8:latest'
      EE_BUILDER_IMAGE: '<hub_fqdn>/ansible-builder-rhel8:latest'
    
    dependencies:
      python: requirements.txt
      galaxy: requirements.yml
    Copy to Clipboard Toggle word wrap
  6. 创建一个 ansible.cfg 文件,指向您的私有自动化中心,其中包含允许上传的凭证,如 admin 用户令牌。

    $ cat ansible.cfg
    [galaxy]
    server_list = private_hub
    
    [galaxy_server.private_hub]
    url=https://<hub_fqdn>/api/galaxy/
    token=<admin_token>
    Copy to Clipboard Toggle word wrap
  7. 创建一个指向断开连接的 UBI 存储库镜像的 ubi.repo 文件(如果托管 UBI 内容,这可能是您的 Satellite)。

    这是一个示例输出,其中 reposync 用于镜像 UBI 仓库。

    $ cat ubi.repo
    [ubi-8-baseos]
    name = Red Hat Universal Base Image 8 (RPMs) - BaseOS
    baseurl = http://<ubi_mirror_fqdn>/repos/ubi-8-baseos
    enabled = 1
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    gpgcheck = 1
    
    [ubi-8-appstream]
    name = Red Hat Universal Base Image 8 (RPMs) - AppStream
    baseurl = http://<ubi_mirror_fqdn>/repos/ubi-8-appstream
    enabled = 1
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    gpgcheck = 1
    Copy to Clipboard Toggle word wrap
  8. 添加用于为私有自动化中心 web 服务器证书签名的 CA 证书。

    1. 对于自签名证书(安装程序默认),从您的私有自动化中心中生成文件 /etc/pulp/certs/root.crt 并将其命名为 hub-root.crt
    2. 如果使用内部证书颁发机构来请求和签署私有自动化中心 web 服务器证书,请复制该 CA 证书,名为 hub-root.crt
  9. 使用您的自定义 EE 镜像所需的内容创建 python requirements.txt 和 ansible 集合 requirements.yml。请注意,您需要的任何集合都应上传到您的私有自动化中心中。
  10. 使用 ansible-builder 创建用于构建 EE 镜像的上下文目录。

    $ ansible-builder create
    Complete! The build context can be found at: /home/cloud-user/custom-ee/context
    $ ls -1F
    ansible.cfg
    context/
    execution-environment.yml
    hub-root.crt
    pip.conf
    requirements.txt
    requirements.yml
    ubi.repo
    Copy to Clipboard Toggle word wrap
  11. 将用于覆盖面向互联网的默认值的文件复制到上下文目录中。

    $ cp ansible.cfg hub-root.crt pip.conf ubi.repo context/
    Copy to Clipboard Toggle word wrap
  12. 编辑文件 context/Containerfile 并添加以下修改。

    1. 在第一个 EE_BASE_IMAGE 构建部分中,添加 ansible.cfghub-root.crt 文件,并运行 update-ca-trust 命令。
    2. EE_BUILDER_IMAGE 构建部分中,添加 ubi.repopip.conf 文件。
    3. 在最终的 EE_BASE_IMAGE 构建部分中,添加 ubi.repo 和 pip.conf 文件。

      $ cat context/Containerfile
      ARG EE_BASE_IMAGE=<hub_fqdn>/ee-supported-rhel8:latest
      ARG EE_BUILDER_IMAGE=<hub_fqdn>/ansible-builder-rhel8:latest
      
      FROM $EE_BASE_IMAGE as galaxy
      ARG ANSIBLE_GALAXY_CLI_COLLECTION_OPTS=
      USER root
      
      ADD _build /build
      WORKDIR /build
      
      # this section added
      ADD ansible.cfg /etc/ansible/ansible.cfg
      ADD hub-root.crt /etc/pki/ca-trust/source/anchors/hub-root.crt
      RUN update-ca-trust
      # end additions
      RUN ansible-galaxy role install -r requirements.yml \
          --roles-path /usr/share/ansible/roles
      RUN ansible-galaxy collection install \
          $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml \
          --collections-path /usr/share/ansible/collections
      
      FROM $EE_BUILDER_IMAGE as builder
      
      COPY --from=galaxy /usr/share/ansible /usr/share/ansible
      
      ADD _build/requirements.txt requirements.txt
      RUN ansible-builder introspect --sanitize \
          --user-pip=requirements.txt \
          --write-bindep=/tmp/src/bindep.txt \
          --write-pip=/tmp/src/requirements.txt
      # this section added
      ADD ubi.repo /etc/yum.repos.d/ubi.repo
      ADD pip.conf /etc/pip.conf
      # end additions
      RUN assemble
      
      FROM $EE_BASE_IMAGE
      USER root
      
      COPY --from=galaxy /usr/share/ansible /usr/share/ansible
      # this section added
      ADD ubi.repo /etc/yum.repos.d/ubi.repo
      ADD pip.conf /etc/pip.conf
      # end additions
      
      COPY --from=builder /output/ /output/
      RUN /output/install-from-bindep && rm -rf /output/wheels
      Copy to Clipboard Toggle word wrap
  13. 使用 podman 命令在本地 podman 缓存中创建 EE 镜像。

    $ podman build -f context/Containerfile \
        -t <hub_fqdn>/custom-ee:latest
    Copy to Clipboard Toggle word wrap
  14. 自定义 EE 镜像构建成功后,将其推送到私有自动化中心。

    $ podman push <hub_fqdn>/custom-ee:latest
    Copy to Clipboard Toggle word wrap

要在 Ansible Automation Platform 2 的次发行版本间升级,请使用这个常规工作流。

流程

  1. 下载并解压缩最新的 Ansible Automation Platform 2 安装捆绑包。
  2. 备份现有安装。
  3. 将现有安装清单文件复制到新的安装捆绑包目录中。
  4. 运行 ./setup.sh 以升级安装。

例如,要从 2.2.0-7 升级到 2.3-1.2,请确保两个设置捆绑包都位于安装发生的初始控制器节点上:

    $ ls -1F
ansible-automation-platform-setup-bundle-2.2.0-7/
ansible-automation-platform-setup-bundle-2.2.0-7.tar.gz
ansible-automation-platform-setup-bundle-2.3-1.2/
ansible-automation-platform-setup-bundle-2.3-1.2.tar.gz
Copy to Clipboard Toggle word wrap

备份 2.2.0-7 安装:

$ cd ansible-automation-platform-setup-bundle-2.2.0-7
$ sudo ./setup.sh -b
$ cd ..
Copy to Clipboard Toggle word wrap

将 2.2.0-7 清单文件复制到 2.3-1.2 捆绑包目录中:

$ cd ansible-automation-platform-setup-bundle-2.2.0-7
$ cp inventory ../ansible-automation-platform-setup-bundle-2.3-1.2/
$ cd ..
Copy to Clipboard Toggle word wrap

使用 setup.sh 脚本从 2.2.0-7 升级到 2.3-1.2 :

$ cd ansible-automation-platform-setup-bundle-2.3-1.2
$ sudo ./setup.sh
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat