2016-12-08 47 views
0

在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'''「'''

回答

0

Ansible「command」中不允許使用&。

command: sh /usr/jboss/bin/run.sh -c XXXXXXXX -b x.x.x.x & 

嘗試刪除它或使用shell而不是命令。

Ansible documentation about command

給定的命令[...]不會 可以通過外殼處理,所以像$ HOME變量和操作 像 「<」, 「>」, 「|」 ,「;」和「&」將不起作用(如果需要這些功能,請使用外殼模塊 )。