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
评论区