1

i have an open-source program i want to run from ansible basically ansible will go into the node and run "./Program.Name" which will start the program but when ansible-playbook is done the program closes is there a way I can start the program and keep it running even after ansible is done? I was told there is the async module but how can I write the playbook so it will keep the program running for as long as the node is up. Please try to provide the yml code if possible where I can replace the name of the program and it should do the job

I have tried to run the porcess with "./Program.Name &" but it does not stay running.

sajjad
  • 13
  • 3
  • Possible dup of https://stackoverflow.com/questions/39347379/ansible-run-command-on-remote-host-in-background ? – user3486184 Aug 14 '19 at 22:05
  • May need to add `nohup` to your shell command. For example `nohup ./Program.Name >/dev/null 2>&1 &`. This will stop the process being killed when the user disconnects – Matt P Aug 15 '19 at 00:20

2 Answers2

0

async poll = 0

just never check back in on the task

https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#concurrent-tasks-poll-0

Adam Miller
  • 752
  • 3
  • 6
0

The following methods may be useful to you, and the async and poll parameters are necessary,more info see ansible doc

- name: run
  shell: "( tail > /dev/null 2>&1 &)"
  async: 10
  poll: 0

Note: If you want to run the program with a daemon, I think supervisord may be more appropriate.

Gourds
  • 61
  • 5