Ansible—— 17. yum_repository模块

yum_repository模块可以帮助我们管理远程主机上的yum仓库。

1. 参数

name:必须参数,用于指定要操作的唯一的仓库ID,也就是".repo"配置文件中每个仓库对应的"中括号"内的仓库ID
baseurl:此参数用于设置yum仓库的baseurl
description:此参数用于设置仓库的注释信息,也就是".repo"配置文件中每个仓库对应的"name字段"对应的内容。
file:此参数用于设置仓库的配置文件名称,即设置".repo"配置文件的文件名前缀,在不使用此参数的情况下,默认以name参数的仓库ID作为".repo"配置文件的文件名前缀,同一个’.repo’配置文件中可以存在多个yum源
enabled:此参数用于设置是否激活对应的yum源,此参数默认值为yes,表示启用对应的yum源,设置为no表示不启用对应的yum源。
gpgcheck:此参数用于设置是否开启rpm包验证功能,默认值为no,表示不启用包验证,设置为yes表示开启包验证功能。
gpgcakey:当gpgcheck参数设置为yes时,需要使用此参数指定验证包所需的公钥
state:默认值为present,当值设置为absent时,表示删除对应的yum源

2. 示例
ansible test70 -m yum_repository -a 'name=aliEpel description="alibaba EPEL" baseurl=https://mirrors.aliyun.com/epel/$releasever\Server/$basearch/'
ansible test70 -m yum_repository -a 'name=aliEpel description="alibaba EPEL" baseurl=https://mirrors.aliyun.com/epel/$releasever\Server/$basearch/ file=alibaba'
ansible test70 -m yum_repository -a 'name=local baseurl=file:///media description="local cd yum" enabled=no'
ansible test70 -m yum_repository -a 'name=local baseurl=file:///media description="local cd yum" gpgcheck=yes gpgcakey=file:///media/RPM-GPG-KEY-CentOS-7'

删除/etc/yum.repos.d/alibaba.repo配置文件中的aliEpel源

ansible test70 -m yum_repository -a 'file=alibaba name=aliEpel state=absent'

————Blueicex 2020/3/27 12:30 blueice1980@126.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值