CW_LAB
CW_LAB

Reputation: 51

Ansible hangs executing playbook command

I'm running into an issue using where ansible hangs completely when running a task. The task it hangs on is where a java -jar command is being run using the command module.

ansible_hanging.img

The odd thing is that playbook does execute the command succesfully as the process output shows below on the remote server.

[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.

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- 2.9.7 python- 3.8.2 remote_server os: Centos7

Upvotes: 2

Views: 3016

Answers (1)

CW_LAB
CW_LAB

Reputation: 51

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.

- 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

Upvotes: 3

Related Questions