Ansible停止执行剧本命令

问题描述 投票:0回答:1

我在运行任务时遇到ansible完全挂起的问题。它挂起的任务是使用命令模块运行java -jar命令的位置。

ansible_hanging.img

奇怪的是,剧本确实成功执行了命令,如远程服务器上下面的过程输出所示。

[nexus@kubem00 nexusiq-server]$ ps -aux | grep java
nexus    12739 11.7 21.0 3068128 395608 pts/2  Sl+  19:25   0:16 java -jar nexus-iq-server-1.91.0-01.jar server config.yml
nexus    12803  0.0  0.0 112808   968 pts/1    S+   19:27   0:00 grep --color=auto java

[我感觉到我的错误与事实有关,因为它作为前台任务运行,因为当我中断使用ctrl + c运行的悬而未决的剧本时,远程服务器上正在运行的Java服务被杀死。

[我也尝试过使用ansible shell module命令在没有运气的情况下在有和没有'&'的情况下运行它。

ansible- 2.9.7python- 3.8.2remote_server操作系统:Centos7

java ansible yaml nexus playbook
1个回答
0
投票

在几次将头撞到墙上后,我设法使其正常工作。

我不得不切换回shell模块并使用'nohup'命令,它似乎正在工作。

- name: Run NexusIQ server
  become: yes
  become_user: nexus
  shell: nohup java -jar nexus-iq-server-1.91.0-01.jar server config.yml &
  args:
    chdir: /opt/nexusiq-server
© www.soinside.com 2019 - 2024. All rights reserved.