ansible 启动tomcat/停止tomcat

原创
2019/05/21 17:23
阅读数 1.2K

用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 &
1
2
3
4
5
6
7
如果有报错说权限不够,就给startup.sh的执行权限

chmod u+x /opt/dev/tomcat7/apache-tomcat-7.0.65/bin/startup.sh
1
停止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
--------------------- 
作者:金柱 
来源:CSDN 
原文:https://blog.csdn.net/a506681571/article/details/78063464 
版权声明:本文为博主原创文章,转载请附上博文链接!

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
0 收藏
0
分享
返回顶部
顶部