ansible-playbook 顯示命令返回結果


---
- hosts: test
  gather_facts: F   #開啟debug
  vars:
    war: "ps -ef | grep tomcat | grep -v grep | awk '{print $2}'"
  tasks:
  - name: stop tomcat
    shell: nohup /bin/bash /tmp/stop_tomcat.sh&
    ignore_errors: True
    register: tomcat_out  #定義變量存儲返回的結果
  - name: show 結果       #定義輸出結果的task
    debug: var=tomcat_out verbosity=0    #debug的模塊顯示輸出的記過
  - name: back war
    shell: cp /home/admin/taobao-tomcat-production-7.0.59.3/deploy/ROOT.war /tmp/
  - name: remove romate dir
    file: path=/home/admin/taobao-tomcat-production-7.0.59.3/deploy/ROOT state=absent
  - name: remove romate war
    file: path=/home/admin/taobao-tomcat-production-7.0.59.3/deploy/ROOT.war state=absent
  - name: copy war
    copy: src=/home/admin/.jenkins/jobs/NET-hangfa/workspace/aecc_purchase_portal_web/xx.war  dest=/home/admin/taobao-tomcat-production-7.0.59.3/deploy/ROOT.war owner=admin group=wheel mode=0644
  - name: start tomcat
    shell: nohup sh /home/admin/taobao-tomcat-production-7.0.59.3/bin/startup.sh &
  - name: tomcatalive
    shell: "{{war}}"
    register: check
  - name: show
    debug: var=check.stdout verbosity=0    #check.stdout 顯示出的信息會看的更清晰點

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM