gpt4 book ai didi

linux - 如何在ansible中使用yum模块禁用所有存储库?

转载 作者:行者123 更新时间:2023-12-03 09:59:32 24 4
gpt4 key购买 nike

我正在尝试禁用所有 yum 存储库并仅启用 1 个存储库来安装 yum 包。如何使用 yum 模块禁用所有存储库?

尝试使用 disablerepo='*' 但不确定这是否是正确的方法

- name: Update the uek kernel pkg on gateways
yum:
name: "{{ packages }}"
disablerepo: "*"
enablerepo: test_iso
vars:
packages:
- kernel-uek
become_user: root

最佳答案

Ansible documentation建议您必须提供以逗号分隔的 repo id 列表。

disablerepo: Repoid of repositories to disable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". As of Ansible 2.7, this can alternatively be a list instead of "," separated string



文档中的示例:
- name: Install package with multiple repos disabled
yum:
name: sos
disablerepo: "epel,ol7_latest"

您可能会考虑使用 yum_repository模块作为替代方案:
# Example removing a repository and cleaning up metadata cache
- name: Remove repository (and clean up left-over metadata)
yum_repository:
name: epel
state: absent
notify: yum-clean-metadata

关于linux - 如何在ansible中使用yum模块禁用所有存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55845125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com