我无法使用Ansible启动或停止tomcat。我正在尝试在其他系统上停止tomcat,它给出了致命错误,但它能够通过ssh登录,使用ansible ping命令,创建文件和目录。 弹出的错误是:
失败! => {“更改”:true,“ cmd”:[“ sh”,“ / opt / tomcat / bin / shutdown.sh”],“ delta”:“ 0:00:00.002163”,“结束”:“ 2019年-06-18 12:43:23.218056“,” msg“:”非零返回码“,” rc“:127,”开始“:” 2019-06-18 12:43:23.215893“,” stderr“: “ sh:0:无法打开/opt/tomcat/bin/shutdown.sh","stderr_lines":["sh:0:无法打开/opt/tomcat/bin/shutdown.sh"],"stdout “:”“,” stdout_lines“:[]}
yaml文件为:
---
- hosts: test-servers
tasks:
- name: Make sure that we can connect to the machine
ping:
- name: Stop Tomcat
command: sh /opt/tomcat/bin/shutdown.sh
become: sudo
become_user: tomcat