码迷,mamicode.com
首页 > 其他好文 > 详细

ansible的使用

时间:2017-05-09 22:30:12      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:软件   success   

一。安装软件

1.查看是否有安装软件

ansible host31 -m shell -a "rpm -qa |grep httpd"

如果显示host31 | FAILED | rc=1 >>  则表示没安装

如果显示

172.16.10.239 | success | rc=0 >>

httpd-tools-2.2.15-54.el6.centos.x86_64

httpd-2.2.15-54.el6.centos.x86_64

则表示已安装。


2.使用yum模块安装httpd:

ansible host31 -m yum -a “name=httpd”


二。启动服务

1.查看服务是否是启动状态

ansible a -m shell -a "service httpd status"

也可以ansible a -m command -a "service httpd status"

172.16.10.239 | FAILED | rc=3 >>

httpd is stopped

2.使用service模块启动httpd

ansible host31 -m service -a "name=httpd state=started"

关闭httpd

ansible host31 -m service -a "name=httpd state=stopped"


三 。

使用service模块重启httpd并设定开机自启


ansible host31 -m service -a "name=httpd enabled=yes state=restarted"


四。

使用yum模块删除httpd

ansible host31 -m yum -a "name=httpd state=absent"

ansible的使用

标签:软件   success   

原文地址:http://406647516.blog.51cto.com/2249087/1923841

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!