ansible-yum_repository模块使用方法

应用

yum_repository模块管理远程主机上的yum仓库

参数

  • name:相当于.repo文件定义中括号的[仓库ID]
  • baseurl:相当于.repo文件中baseurl
  • description:相当于.repo文件中的name
  • file:相当于.repo文件的名称,不使用时默认以name加.repo命令
  • enabled=yes|no:相当于.repo文件中enabled
  • gpgcheck=yes|no:相当于.repo文件中gpgcheck
  • gpgcakey:前提是gpgcheck=yes,相当于.repo文件中gpgkey,验证gpg公钥
  • state=present|absent:默认present,absent表示删除

示例

  1. 创建阿里云epel源
]# ansible all -m yum_repository -a 'name=aliepel baseurl=https://mirrors.aliyun.com/epel/7/x86_64/ enabled=yes gpgcheck=yes gpgcakey=https://mirrors.aliyun.com/epel/RPM-GPG-KEY-EPEL-7 state=present file=AlicloudEpel'
  1. 删除阿里云epel源
]# ansible all -m yum_repository -a 'file=AlicloudEpel name=aliepel state=absent'
posted @ 2020-05-21 12:04  wanwz  阅读(2264)  评论(0编辑  收藏  举报