If I ran the nohup node /tmp/test-app/index.js > /tmp/test-app/nohup.out 2>&1 & command in my Linux console, it works. It starts the node.js server in the background and I am able to see the running process using the command ps aux | grep node.
However, if I ran the exact same command as a task in my Playbook, the Playbook executes and the task is marked as changed, but it actually doesn't start the node server.
I have checked /var/log/messages and have verbose logged the Playbook execution with -vvv. The command seems to be going to the Linux console, but the node server doesn't seem to start from the Playbook (but it does start if just execute the command directly on the console.
Please let me know how to fix this.
Here's the Playbook task:
---
- name: Test app
hosts: all
gather_facts: true
vars:
tmp_dir: '/tmp/test-app'
tasks:
- name: Start the demo app in the background
shell: 'nohup node /tmp/test-app/index.js > /tmp/test-app/nohup.out 2>&1 &'
args:
chdir: '{{tmp_dir}}'