启动服务
name: Start the service
service:
name: httpd
state: started
停止服务
name: Stop the service
service:
name: httpd
state: stopped
重启服务
name: Restart the service
service:
name: httpd
state: restarted
检查服务状态
name: Check service status
service:
name: httpd
state: status
如果服务启动/停止失败,需要检查上述可能的原因,并在Playbook中相应地调整或调试,记得使用become: yes(对于旧版本是sudo: yes)如果需要以root用户或其它用户身份运行这些命令。