ansible run command on remote host in background

Question:

I am trying to start filebeat (or for that matter any other process which will run continuously on demand) process on multiple hosts using ansible. I don’t want ansible to wait till the process keeps on running. I want ansible to fire and forget and come out and keep remote process running in back ground.
I’ve tried using below options:

Answer:

Simplified answer :

Note subshell parentheses.

Update: actually, you should be fine without async, just don’t forget to redirect stdout:

Leave a Reply