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"

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...