ansible 管理服务

2018-08-05

ansible 管理服务

 模块 yum

  安装一个包

[root@server ~]# ansible client.test.com -m yum -a "name=httpd"

 在 name 后面还可以加上 state=installed,不加也能安装

  管理服务 service 模块

[root@server ~]# ansible client.test.com -m service -a "name=httpd state=started enabled=no"    //启动服务,不开机启动

client.test.com | SUCCESS => {

    "changed": true,

    "enabled": false,

    "name": "httpd",

    "state": "started"

}


[root@server ~]# ansible client.test.com -m service -a "name=httpd state=stopped enabled=yes"

client.test.com | SUCCESS => {

    "changed": true,

    "enabled": true,

    "name": "httpd",

    "state": "stopped"

}

 ansible 文档的使用

 列出所有模块

[root@server ~]# ansible-doc -l

 列出指定模块

[root@server ~]# ansible-doc service

标题:ansible 管理服务
作者:散宜生
地址:https://17kblog.com/articles/2018/08/05/1533442304832.html