我在剧本中有一个任务,试图照常通过处理程序重启nginx:
name: restart nginx
service: name=nginx state=restarted
它给了我以下错误:
RUNNING HANDLER [webtier : restart nginx] **************************************
fatal: [vagrant]: FAILED! => {"changed": false,"msg": "Unable to restart service nginx: Failed to restart nginx.service: Connection timed out\nSee system logs and 'systemctl status nginx.service' for details.\n"}
但是直到最后一次 sudo:是命令仍在起作用。并且上面的错误不会出现。
但是这次,通过添加 sudo:是命令
name: restart nginx
service: name=nginx state=restarted
sudo: yes
给出以下错误:
ERROR! conflicting action statements: service,sudo
The error appears to be in '/Users/mac/Documents/GitHub/petalandstem/ansible/roles/webtier/handlers/main.yml': line 28,column 3,but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: restart nginx
^ here
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
如何成功重启nginx?