yum_repository模块用于在基于RPM的Linux发行版中添加或删除YUM仓库。shell
yum_repository模块经常使用参数网络
name:必须参数,指定惟一的仓库ID,state为present或absent时须要设置name参数
baseurl:指定yum仓库repodata目录的URL,能够是多个,若是设置为多个,须要使用"metalink"和"mirrorlist"参数
enabled:使用此yum仓库
gpgcheck:是否对软件包执行gpg签名检查
gpgkey:gpg秘钥的URL
mode:权限设置,当设置为preserve时,文件将与源文件权限相同
file:用于设置仓库的配置文件名称,即设置”.repo”配置文件的文件名前缀,在不使用此参数的状况下,默认以 name 参数的仓库ID做为”.repo”配置文件的文件名前缀,同一个”.repo” 配置文件中能够存在多个 yum 源
state:状态,默认的present为安装此yum仓库,absent为删除此yum仓库
description:设置仓库的注释信息
async:若是yum仓库支持并行,yum将并行下载软件包和元数据
bandwidth:与throttle参数一块儿使用,限制yum可用的网络带宽async
yum_repository模块示例
安装yum仓库ide
- name: install yum repo yum_repository: name: rh294_BASE state: present description: RHCE8.0 test baseurl: http://content.example.com/rhel8.0/x86_64/dvd/BaseOS gpgcheck: yes gpgkey: http://content.example.com/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-releas enabled: yes
卸载yum仓库url
tasks: - name: uninstall yum repo yum_repository: name: rh294_BASE state: absent notify: yum-clean-metadata handlers: - name: clean yum cache shell: yum clean metadata
参考:ansible-doc yum_repositorycode