ansible 启动tomcat/停止tomcat,ansibletomcat
ansible 启动tomcat/停止tomcat,ansibletomcat
用service模块写的playbook执行完了,目标机器的tomcat状态没变,这个希望大神指导一下!!!
下面是用shell模块写的playbook内容。
启动tomcat
---
- hosts: vm
remote_user: root
tasks:
- name: 启动tomcat
shell: nohup /opt/dev/tomcat7/apache-tomcat-7.0.65/bin/startup.sh &
如果有报错说权限不够,就给startup.sh的执行权限
chmod u+x /opt/dev/tomcat7/apache-tomcat-7.0.65/bin/startup.sh
停止tomcat
---
- hosts: vm
remote_user: root
tasks:
- name: 停止tomcat
shell: ps -fe | grep "/opt/dev/tomcat7/apache-tomcat-7.0.65" | grep -v grep | tr -s " "|cut -d" " -f2 | xargs kill -9
tomcat的路径要改成你实际的绝对路径。
评论暂时关闭