文章目录

Yum 模块

功能:使用yum软件包管理器安装,升级,降级,删除和列出软件包和组。

官方文档:https://docs.ansible.com/ansible/latest/modules/yum_repository_module.html#yum-repository-module

常用参数:

参数参数选项说明
conf_file指定远程主机yum源位置
name指定要安装的包,如果有多个版本需要指定版本,否则安装最新的包
disable_gpg_check关闭gpg_check
disablerepo禁用某个yum源
enablerepo启用某个yum仓库
state安装状态
state=latest如果安装的软件存在则进行更新,如果不存在则安装最新版
state=present如果安装的软件存在则不进行安装,如果不存在则安装
state=install正常安装
state=absent删除软件包
state=removed卸载软件包

示例:

  • 安装一个 http 服务
[root@master ~]# ansible dong -m yum -a "name=httpd state=present"
  • 卸载软件包
[root@master ~]# ansible dong -m yum -a "name=httpd state=removed"
  • 删除软件包
[root@master ~]# ansible dong -m yum -a "name=httpd state=absent"

 
 
 
 
 

更多推荐