yum模块
语法格式
[root@ansible ~]# ansible web -m yum -a "name=httpd state=installed" 参数 name //指定要安装软件包的名称,如果有多个用","隔开 state //指定使用yum的方法 installed|present //安装软件包 removed|absent //移除软件包 latest //安装最新软件包
案例1:安装已存在的软件包
[root@ansible ~]# ansible web -m yum -a "name=httpd,ftp state=installed" 192.168.81.220 | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "msg": "", "rc": 0, "results": [ "httpd-2.4.6-88.el7.centos.x86_64 providing httpd is already installed", "ftp-0.17-67.el7.x86_64 providing ftp is already installed" ] }
案例2:删除指定的安装包
[root@ansible ~]# ansible web -m yum -a "name=httpd,ftp state=removed"
案例3:安装指定软件(present)
[root@ansible ~]# ansible web -m yum -a "name=httpd,ftp state=present"