7、ansible-Ad-Hoc-点对点模式--m service-服务模块(启动、停止、重启)
启动服务:
ansible webserver -m service -a 'name=httpd state=started'
设置开机自启
ansible webserver -m service -a 'name=httpd state=started enabled='yes''
·· 如果enabled=no 表示禁止开机自启
停止服务
ansible webserver -m service -a 'name=httpd state=stopped'
重启服务
ansible webserver -m service -a 'name=httpd state=restarted'