community.general.rhsm_repository 模块 – 使用 subscription-manager 命令管理 RHSM 仓库

注意

此模块是 community.general 集合 (版本 10.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要满足其他要求才能使用此模块,有关详细信息,请参阅 要求

要在 playbook 中使用它,请指定:community.general.rhsm_repository

概要

  • 使用 subscription-manager 命令管理 (启用/禁用) Red Hat 订阅管理授权平台的 RHSM 仓库。

要求

执行此模块的主机需要以下要求。

  • subscription-manager

参数

参数

注释

name

列表 / 元素=字符串 / 必需

要启用的仓库的 ID。

要操作多个仓库,这可以接受逗号分隔的列表或 YAML 列表。

purge

布尔值

禁用当前启用的且未在 name 中指定的全部仓库。只有在将仓库列表传递给 name 字段时,才将其设置为 true。与 loop 一起使用很可能不会得到预期的结果。

选项

  • false ← (默认)

  • true

state

字符串

如果 state 等于 present 或 disabled,则表示所需的仓库状态。

在 community.general 10.0.0 中,状态 presentabsent 已被移除。请改用 enableddisabled

选项

  • "enabled" ← (默认)

  • "disabled"

属性

属性

支持

描述

check_mode

支持:完全支持

可以在 check_mode 下运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:完全支持

在差异模式下,将返回有关已更改内容(或在 check_mode 下可能需要更改的内容)的详细信息。

注释

注意

  • 为了管理 RHSM 仓库,系统必须已经手动注册到 RHSM,或者使用 Ansible community.general.redhat_subscription 模块。

  • 只有 root 用户才能与 subscription-manager 交互,因此需要 root 权限才能成功运行此模块。

示例

- name: Enable a RHSM repository
  community.general.rhsm_repository:
    name: rhel-7-server-rpms

- name: Disable all RHSM repositories
  community.general.rhsm_repository:
    name: '*'
    state: disabled

- name: Enable all repositories starting with rhel-6-server
  community.general.rhsm_repository:
    name: rhel-6-server*
    state: enabled

- name: Disable all repositories except rhel-7-server-rpms
  community.general.rhsm_repository:
    name: rhel-7-server-rpms
    purge: true

返回值

常用的返回值已在 此处 记录,以下是此模块特有的字段

描述

repositories

列表 / 元素=字符串

带有其状态的 RHSM 仓库列表。

当此模块用于更改仓库状态时,此列表包含更改后更新的状态。

返回:成功

作者

  • Giovanni Sciortino (@giovannisciortino)