ansible test -m shell -a /data/tomcat/bin/startup.sh

test | SUCCESS | rc=0 &>&>ansible顯示執行完成 ,(也有可能是沒有做任何動作 )

tomcat就是啟動不起來 哪位大神給指點下 用ansible tomcat的啟動 停止

tomcat 7 ansible 2.1.1.0用playbook也是如此

- name: start tomcat.
action: shell {{ tomcat_root }}/../../bin/catalina.sh start
(這裡只顯示playbookne一部分容 變數都已存在)


其他命令都正常么?比如

touch /tmp/teststart.sh許可權沒問題吧?可以在引號中命令 加「 &>&>/tmp/log」看這log里有沒有輸出內容,


在tomcat的啟動腳本startup.sh 添加一句 source /etc/profile 解決找不到JAVA環境變數問題playbook如下:

- name: start tomcat service
shell: chdir={{ tomcat_service_dir }}/bin nohup ./startup.sh


碰到ansible無法起停tomcat的時候,有兩個點需要關注1、環境變數,在startup.sh中添加source /etc/profile

2、後台運行,加上nohup...

今天遇到這個問題,現已經解決
set -m;start tomcat在啟動tomcat的前面加set -m


不知道你解決了沒有,沒有的話,我告訴你,你這個問題其實在用docker,在容器外面啟動的時候也是啟動不起來的,終端被佔用的結果。你參考下我這個: ansible web-2 -a nohup /usr/local/tomcat/bin/startup.sh 加上 nohup ... 讓他在後台另外一個終端中啟動。

直接用nohup還是不行的,shell命令里加入set -m就可以了,例如:source .bash_profile;set -m;nohup ./startup.sh


推薦閱讀:
相关文章