如何使用 `yum` 模块在 Ansible 中清理和缓存 yum 存储库?

问题描述 投票:0回答:1

Ansible 有

yum
模块,

我们可以用它来安装包:

​ansible all -m yum -a 'name=vim state=latest'  

但是如何使用它来执行 clean 和 make cache 命令呢? 我只知道脚本方式:

ansible all -m shell -a 'yum clean all'
ansible all -m shell -a 'yum makecache'

那么,如何使用

yum
模块来清理和缓存 yum 存储库?

ansible yum
1个回答
5
投票

你的做法是正确的。

- shell: yum clean all

Ansible 中并未实现您想要的方式。

来自文档

“yum模块不支持幂等方式清除yum缓存,所以决定不实现,唯一的方法是使用command,直接调用yum命令,即‘command: yum clean all’,issue

© www.soinside.com 2019 - 2024. All rights reserved.