1. yum_repository模块
# 配置yum源
[root@server4 testdir]# ansible testB -m yum_repository -a "name=rhel7.5 description='ansible_yum' baseurl=http://172.25.60.250/rhel7.5 gpgcheck=no enabled=yes"
2. yum模块
# 安装软件
[root@server4 testdir]# ansible testB -m yum -a "name=gcc disable_gpg_check=yes"
[root@server4 testdir]# ansible testB -m yum -a "name=gcc state=present disable_gpg_check=yes"
[root@server4 testdir]# ansible testB -m yum -a "name=gcc state=installed disable_gpg_check=yes"
# 安装最新版本
[root@server4 testdir]# ansible testB -m yum -a "name=gcc state=installed disable_gpg_check=yes"
# 卸载
[root@server4 testdir]# ansible testB -m yum -a "name=gcc state=absent"
[root@server4 testdir]# ansible testB -m yum -a "name=gcc state=removed"