community.general.dnf_config_manager 模块 – 使用 config-manager 启用或禁用 dnf 仓库

注意

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

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

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

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

community.general 8.2.0 中的新功能

概要

  • 此模块使用 dnf config-manager 子命令启用或禁用仓库。

要求

以下是在执行此模块的主机上所需的要求。

  • dnf

  • dnf-plugins-core

参数

参数

注释

name

列表 / 元素=字符串

仓库 ID,例如 crb

默认值: []

state

字符串

仓库应为 enabled 还是 disabled

选项

  • "enabled" ← (默认)

  • "disabled"

属性

属性

支持

描述

check_mode

支持: 完整

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

diff_mode

支持:

在 diff 模式下,将返回已更改的内容的详细信息(或者在 check_mode 中可能需要更改的内容)。

另请参阅

另请参阅

ansible.builtin.dnf

使用 dnf 包管理器管理软件包。

ansible.builtin.yum_repository

添加或删除 YUM 仓库。

示例

- name: Ensure the crb repository is enabled
  community.general.dnf_config_manager:
    name: crb
    state: enabled

- name: Ensure the appstream and zfs repositories are disabled
  community.general.dnf_config_manager:
    name:
      - appstream
      - zfs
    state: disabled

返回值

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

描述

changed_repos

列表 / 元素=字符串

已更改的仓库。

返回:成功

示例: ["crb"]

repo_states_post

字典

执行操作后仓库的状态。

返回:成功

示例: {"disabled": ["appstream-debuginfo", "appstream-source", "baseos-debuginfo", "baseos-source", "crb-debug", "crb-source"], "enabled": ["appstream", "baseos", "crb"]}

disabled

列表 / 元素=字符串

已禁用的仓库 ID。

返回:成功

enabled

列表 / 元素=字符串

已启用的仓库 ID。

返回:成功

repo_states_pre

字典

执行操作之前仓库的 ID。

返回:成功

示例: {"disabled": ["appstream-debuginfo", "appstream-source", "baseos-debuginfo", "baseos-source", "crb-debug", "crb-source"], "enabled": ["appstream", "baseos", "crb"]}

disabled

列表 / 元素=字符串

已禁用的仓库 ID。

返回:成功

enabled

列表 / 元素=字符串

已启用的仓库 ID。

返回:成功

作者

  • Andrew Hyatt (@ahyattdev)