gotmax23.update
Ansible 角色: update
这是一个 Ansible 角色,用于检查并可选择安装系统更新。它还可以选择打印可升级的软件包,而不实际进行升级。
Beta 警告
此角色目前处于 beta 版本,且不适用于生产环境。版本之间可能会发生重大更改,请务必查看发布说明。
要求
此角色依赖于某些不包含在 ansible-core 中的集合。
要安装此角色的依赖项,请创建一个 requirements.yml
文件,内容如下:
---
collections:
- name: community.general
然后,如果您使用的是 ansible-base/ansible-core 2.10 或更高版本,请运行以下命令:
ansible-galaxy install -r requirements.yml
如果您仍在使用 Ansible 2.9,请运行以下命令:
ansible-galaxy collection install -r requirements.yml
角色变量
以下是该角色的变量及其默认值,定义在 defaults/main.yml
中。您可以根据需要更改它们,以自定义角色的行为。
---
# update 的默认文件
# 选项:
# - `check` 打印可升级的软件包而不升级它们
# - `full` 打印可升级的软件包,然后升级它们
# - `run` 更新所有软件包而不先列出它们
mode: full
# 此选项设置 apt 升级类型。可用选项有 `dist`、`full`、`safe` 和 `true`。
# 有关更多信息,请参见 [ansible.builtin.apt][1] 模块文档。
update_apt_upgrade_type: true
# 此选项设置 zypper 模块的状态键。
# 选择 `latest` 进行常规升级,或 `dist-upgrade` 进行等效的 `zypper dup`。
# 有关更多信息,请参见 [community.general.zypper][2] 模块文档。
update_zypper_state: latest
# 此选项决定 zypper 是否允许更改供应商
update_zypper_allow_vendor_change: false
# 是否自动移除不需要的依赖项。仅适用于 dnf、yum 和 apt
update_autoremove: false
[1]: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html
[2]: https://docs.ansible.com/ansible/latest/collections/community/general/zypper_module.html
示例剧本
---
- name: 统一
hosts: all
become: true
tasks:
- name: "包含更新"
ansible.builtin.include_role:
name: gotmax23.update
兼容性
此角色使用最新版本的 ansible-core 和 Ansible Galaxy 的最新版本集合进行了测试。这是此角色正式支持的唯一版本。对于其他版本提供尽力支持。
此角色与以下发行版兼容:
发行版 | 版本 |
---|---|
Archlinux | 任何 |
Debian | buster, bullseye, bookworm |
EL | 7, 8 |
Fedora | 34, 35, 36 |
opensuse | 15.3, tumbleweed |
Ubuntu | bionic, focal |
许可
作者
Maxwell G (@gotmax23)
关于项目
Ansible role that checks for and optionally installs system updates. It also has to the option to print upgradeable packages without actually upgrading them.
安装
ansible-galaxy install gotmax23.update
许可证
mit
下载
153
拥有者
@gotmax:matrix.org | Fedora developer. Ansible Community Steering Committee member. Pythonista. | See my sr.ht profile for my current code.