在yaml playbook下面重新啓動jboss服務器,但不回去控制執行下一個命令。我還使用了等待模塊停止等待當前命令結果並轉到下一個命令。但仍然無限期地掛在當前的命令上。當我出錯時,請讓我知道嗎?啓動jboss服務器使用可靠和返回控制
---
- hosts: test1
tasks:
- name: simple command
become: true
command: whoami
register: output
- debug:
msg: "I gave the command whoami and the out is '{{output.stdout}}'"
- name: change to jboss user
become: true
become_user: jboss
command: whoami
register: output
- debug:
msg: "I gave the command whoami and the out is '{{output.stdout}}'"
- name: start jboss server as jboss user
become: true
become_user: jboss
command: sh /usr/jboss/bin/run.sh -c XXXXXXXX -b x.x.x.x &
when: inventory_hostname in groups['test1']
register: restartscript
- debug:
msg: "output of server restart command is '{{restartscript.stdout}}'"
- name: waiting for server to come back
local_action:
module: wait_for
timeout=20
host=x.x.x.x
port=8080
delay=6
state=started
終端輸出消息
ESTABLISH SSH連接對於USER:XXXXXXXXXXX SSH:EXEC sshpass -d12 SSH -vvv -C -o ControlMaster =汽車-o ControlPersist = 60 -o用戶= XXXXXXXXX -o ConnectTimeout = 10 -o ControlPath =/home/tcprod/XXXXXXXXXX/.ansible/cp/ansible-ssh-%h-%p-%r -tt XXXX'/ bin/sh -c'''''sudo -H - S -p「[sudo via ansible,key = hvgwnsbxpkxvbcmtcfvvsplfphdrevxg] password:」-u jboss/bin/sh -c''''''''''''''''''echo BECOME-SUCCESS -hvgwnsbxpkxvbcmtcfvvsplfphdrevxg;/usr/bin/python /tmp/ansible-tmp-XXXXXXXXX.XX-XXXXXXXXXXXXXX/command.py'''''''''''''''''''& & sleep 0'''「'''