ansible之yum模块

前端之家收集整理的这篇文章主要介绍了ansible之yum模块前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

可以提供的status: latest ,present,installed,removed,absent,
present,latest,absent,前3个代表安装,后面2个是卸载

例:在指定节点上安装tree服务

[root@master ~]#ansible all -m yum -a "state=present name=tree"

例:在指定节点上安装httpd服务

[root@master ~]#ansible all -m yum -a "state=present name=httpd"
[root@client01 tmp]# rpm -qa httpd
httpd-2.2.15-54.el6.centos.x86_64

例:在指定节点上安装tree服务
检查服务是不存在的

[root@hdp-m ~]# ansible dr_exp1 -m shell -a "rpm -qa tree"
 [WARNING]: Consider using yum,dnf or zypper module rather than running rpm
192.168.1.142 | SUCCESS | rc=0 >>
127.0.0.1 | SUCCESS | rc=0 >>
192.168.1.137 | SUCCESS | rc=0 >>

执行命令批量安装:
ansible dr_exp1 -m yum -a "state=present name=tree"

执行命令批量删除

[root@hdp-m ~]# ansible dr_exp1 -m yum -a "state=removed name=tree"
[root@hdp-m ~]# ansible dr_exp1 -m yum -a "state=absent name=tree"

猜你在找的Bash相关文章