community.general.dnf_versionlock 模块 – 在基于 dnf
的系统中锁定软件包版本
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.general.dnf_versionlock
。
community.general 4.0.0 中的新功能
概要
使用基于
dnf
的系统中的versionlock
插件锁定软件包版本。此插件采用一组软件包的名称和版本,并排除这些软件包的所有其他版本。这允许您例如保护软件包不被更新到较新版本。反映软件包锁定的插件状态是locklist
。
要求
以下要求需要在执行此模块的主机上满足。
dnf
dnf-plugin-versionlock
参数
参数 |
注释 |
---|---|
不将软件包名称规范解析为 NEVRA 以查找要锁定的特定版本。相反,软件包名称规范按原样使用。这使得可以锁定尚未可用的软件包版本。 选择
|
|
是否将
选择
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:部分
有时,该模块可能会在 |
可以在 |
|
支持:无 |
在差异模式下,将返回有关已更改(或可能需要在 |
备注
注意
在理想情况下,
versionlock
插件应该具有一个试运行选项,以确切了解将要发生的情况。到目前为止,我们必须尽力猜测,使其尽可能接近从其代码推断出的行为。对于大多数想要锁定和解锁软件包特定版本的情况,它的效果相当不错。
示例
- name: Prevent installed nginx from being updated
community.general.dnf_versionlock:
name: nginx
state: present
- name: Prevent multiple packages from being updated
community.general.dnf_versionlock:
name:
- nginx
- haproxy
state: present
- name: Remove lock from nginx to be updated again
community.general.dnf_versionlock:
package: nginx
state: absent
- name: Exclude bind 32:9.11 from installs or updates
community.general.dnf_versionlock:
package: bind-32:9.11*
state: excluded
- name: Keep bash package in major version 4
community.general.dnf_versionlock:
name: bash-0:4.*
raw: true
state: present
- name: Delete all entries in the locklist of versionlock
community.general.dnf_versionlock:
state: clean
返回值
常见的返回值已在此处记录 这里,以下是此模块特有的字段
键 |
描述 |
---|---|
模块执行后的锁定列表。 返回: 成功且(非检查模式或状态为干净) 示例: |
|
模块执行前的锁定列表。 返回: 成功 示例: |
|
版本锁定要添加的软件包名称规范。 返回: 成功 示例: |
|
版本锁定要删除的软件包名称规范。 返回: 成功 示例: |