第 3 章 基于 Satellite Ansible Collection 的模块的 playbook 示例


基于 Satellite Ansible Collection 的模块的所有 playbook 必须包含有关如何连接到 Satellite API 的参数。以下示例使用 Ansible vault 和模块默认组提供这些参数,并使用用户名和密码进行身份验证。如需更多信息,请参阅 第 2 章 使用 Satellite Ansible Collection 中的模块创建 playbook

其他资源

  • 使用 ansible-doc --list redhat.satellite 命令显示您系统上安装的 Satellite Ansible 模块。
  • 如需 Satellite Ansible 模块和其他相关信息的完整列表,请参阅 Red Hat Ansible Automation Platform

3.1. Playbook 示例:启用存储库并创建内容视图

此 playbook 示例使用以下模块:

  • redhat.satellite.repository_set
  • redhat.satellite.content_view

playbook 确保启用了 RHEL 9 软件仓库,并存在包含这些存储库的内容视图。

在运行此 playbook 之前,请确保您已上传了一个清单,并可以访问 Red Hat CDN。

- name: Ensure RHEL 9 repositories are enabled and a content view exists
  hosts: localhost
  vars_files:
    - My_Vault.yml
  module_defaults:
    group/redhat.satellite.satellite:
      username: "{{ My_Username }}"
      password: "{{ My_Password }}"
      server_url: "{{ My_Server_URL }}"
  tasks:
    - name: Ensure RHEL 9 BaseOS repositories are enabled
      redhat.satellite.repository_set:
        name: "Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)"
        organization: "Default Organization"
        product: "Red Hat Enterprise Linux for x86_64"
        repositories:
        - releasever: "9"
        state: enabled
    - name: Ensure RHEL 9 AppStream repositories are enabled
      redhat.satellite.repository_set:
        name: "Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)"
        organization: "Default Organization"
        product: "Red Hat Enterprise Linux for x86_64"
        repositories:
        - releasever: "9"
        state: enabled
    - name: Ensure a content view for RHEL 9 repositories exists
      redhat.satellite.content_view:
        name: "RHEL 9 content view"
        organization: "Default Organization"
        repositories:
          - name: "Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9"
            product: "Red Hat Enterprise Linux for x86_64"
          - name: "Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9"
            product: "Red Hat Enterprise Linux for x86_64"
Copy to Clipboard Toggle word wrap

如需更多信息,请参阅以下命令的 Ansible 模块文档:

  • ansible-doc redhat.satellite.repository_sync
  • ansible-doc redhat.satellite.content_view
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat