Bootstrap FreeKB - Ansible - Control long running task timeout with async and poll
Ansible - Control long running task timeout with async and poll

Updated:   |  Ansible articles

Let's say you have a task in a playbook that might run for a very long time, which could cause the SSH session between the Ansible controller (that's your Ansible server) and managed node to timeout before the task completes. This often is the case when using the command module or shell module to run a script.

---
- hosts: localhost
  tasks:
  - name: long running task
    shell: example.sh
...

 

async and poll can be used to keep the SSH session alive. In this example, async has a value of 3600 seconds (1 hour) which means the SSH session between the Ansible controller and managed node should remain connected for 1 hour. In other words, the SSH session should not time out.

---
- hosts: localhost
  tasks:
  - name: long running task
    shell: example.sh
    async: 3600
    poll: 60
...

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 443625 in the box below so that we can be sure you are a human.