使用ansible yum 模块安装软件时,可能会碰到执行非常慢的情况。
- name: install rpms
yum:
name:
- etcd
state: latest
disablerepo: "*"
enablerepo: some
原因可能是/etc/yum.conf
配置的默认yum源响应非常慢,甚至不可达。
解决办法是增加配置项 install_repoquery: no
,如下:
- name: install rpms
yum:
name:
- etcd
state: latest
disablerepo: "*"
enablerepo: some
install_repoquery: no
install_repoquery
默认配置是yes
。官方释义如:
If repoquery is not available, install yum-utils. If the system is registered to RHN or an RHN Satellite, repoquery allows for querying all channels assigned to the system. It is also required to use the 'list' parameter.
NOTE: This will run and be logged as a separate yum transation which takes place before any other installation or removal.
NOTE: This will use the system's default enabled repositories without regard for disablerepo/enablerepo given to the module.
重点看最后面: 配置为yes
时会使用系统默认启用的yum源,即使你配置了disablerepo
或enablerepo
。