微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐