ansible-service

#service
#查询服务状态

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

#停止服务

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

#启动服务

ansible server01 -m command -a 'service httpd start'

#重启服务

ansible server01 -m command -a 'service httpd restart'
ansible server01 -m service -a "name=httpd state=restarted"

#查看服务启动级别

ansible server01 -m command -a "chkconfig --list httpd"
原文地址:https://www.cnblogs.com/love19791125/p/9370547.html