ansible run command on remote host in background

后端 未结 1 416
清歌不尽
清歌不尽 2020-12-05 00:40

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

相关标签:
1条回答
  • 2020-12-05 01:18

    Simplified answer from link I mentioned in the 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, you should be fine without async, just don't forget to redirect stdout:

    - name: start simple http server in background
      shell: cd /tmp/www; nohup python -mSimpleHTTPServer </dev/null >/dev/null 2>&1 &
    
    0 讨论(0)
提交回复
热议问题