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
  • 1.
  • 2.
  • 3.

例:在指定节点上安装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 >>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

执行命令批量安装:
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"
  • 1.
  • 2.
posted @   勤奋的蓝猫  阅读(4)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
点击右上角即可分享
微信分享提示