ansible run command on remote host in background -


i trying start filebeat (or matter other process run continuously on demand) process on multiple hosts using ansible. don't want ansible wait till process keeps on running. want ansible fire , forget , come out , keep remote process running in ground. i've tried using below options:

    ---     - hosts: filebeat       tasks:       - name: start filebeat option a)  command: filebeat -c filebeat.yml & option b)  command: nohup filebeat -c filebeat.yml & option c)  shell: filebeat -c filebeat.yml &            async: 0 //tried without well. if > 0 waits of time , terminates filebeat process on remote host , comes out.            poll: 0 

simplified answer link mentioned in comment:

--- - hosts: centos-target   gather_facts: no   tasks:     - shell: "(cd /; python -msimplehttpserver >/dev/null 2>&1 &)"       async: 10       poll: 0 

note subshell parentheses.

update: actually, should fine without async, don't forget redirect stdout:

- name: start simple http server in background   shell: cd /tmp/www; nohup python -msimplehttpserver </dev/null >/dev/null 2>&1 & 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -