简体   繁体   English

Ansible 挂起执行 playbook 命令

[英]Ansible hangs executing playbook command

I'm running into an issue using where ansible hangs completely when running a task.我遇到了一个问题,使用 ansible 在运行任务时完全挂起。 The task it hangs on is where a java -jar command is being run using the command module.它挂起的任务是使用命令模块运行 java -jar 命令的位置。

ansible_hanging.img ansible_hanging.img

The odd thing is that playbook does execute the command succesfully as the process output shows below on the remote server.奇怪的是,playbook 确实成功执行了命令,因为远程服务器上的进程 output 如下所示。

[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

I have a feeling my error is related to the fact it runs as a foreground task as when I interrupt the hanging ansible playbook run with ctrl+c the running java service on the remote server is killed.我感觉我的错误与它作为前台任务运行的事实有关,因为当我中断使用 ctrl+c 运行的挂起的 ansible 剧本时,远程服务器上正在运行的 java 服务被杀死。

I have also tried running it using the ansible shell module command with and without '&' to run in the background which I've had no luck with.我也尝试过使用 ansible shell 模块命令运行它,在后台运行我没有运气。

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

After banging my head against a wall a few times I managed to get it working.在我的头撞到墙上几次后,我设法让它工作了。

I had to switch back to the shell module and to use the 'nohup' command and it seems to be working.我不得不切换回 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM