【Absible学习】Ansible常用模块---包管理模块
发布时间:2020-12-15 19:12:58 所属栏目:安全 来源:网络整理
导读:yum_repository模块 yum_repository模块可以管理远程主机上的yum仓库。 模块参数 参数 说明 name 必须参数,用于指定要操作的唯一的仓库ID,也就是".repo"配置文件中每个仓库对应的"中括号"内的仓库ID baseurl 设置yum仓库的baseurl description 设置仓库的
yum_repository模块可以管理远程主机上的yum仓库。 模块参数
[root@Super ~]# ansible 10.15.43.15 -S -R root -m yum_repository -a 'name=aliEpel description="alibaba EPEL" baseurl=https://mirrors.aliyun.com/epel/$releaseverServer/$basearch/ ' 10.15.43.15 | SUCCESS => { "changed": true,"repo": "aliEpel","state": "present" } [root@Super ~]# ansible 10.15.43.15 -S -R root -m shell -a 'ls /etc/yum.repos.d/' 10.15.43.15 | SUCCESS | rc=0 >> aliEpel.repo CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo [root@Super ~]# 在管理主机上设置ID为aliEpel的yum源,仓库配置文件路径为/etc/yum.repos.d/aliEpel.repo [root@Super ~]# ansible 10.15.43.15 -S -R root -m yum_repository -a 'name=aliEpel file=aliEpel state=absent' 10.15.43.15 | SUCCESS => { "changed": true,"state": "absent" } [root@Super ~]# ansible 10.15.43.15 -S -R root -m shell -a 'ls /etc/yum.repos.d/' 10.15.43.15 | SUCCESS | rc=0 >> CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo [root@Super ~]# 删除/etc/yum.repos.d/alibaba.repo配置文件中的aliEpel源
enablerepo参数和disablerepo参数可以同时使用 [root@Super ~]# ansible 10.15.43.15 -S -R root -m yum -a 'name=nginx disable_gpg_check=yes state=installed enablerepo=aliEpel disablerepo=CentOS-Base' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |