Bootstrap FreeKB - Ansible - Pause or sleep in a playbook
Ansible - Pause or sleep in a playbook

Updated:   |  Ansible articles

If you are not familiar with modules, check out Ansible - Getting Started with Modules.

Both the pause module and delay parameter are used to create a pause or delay during task execution.

In this example, a 5 second pause is made after invoking the shell module.

---
- hosts: all
  tasks:
    - name: kill pid 12345
      shell: kill -9 12345

    - name: 5 second pause
      pause:
        seconds: 5
...

 

Something like this should be returned.

PLAY [all]

TASK [kill pid 12345]
changed: [server1.example.com]
changed: [server2.example.com]
changed: [server3.example.com]

TASK [3 second pause]
Pausing for 3 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)

PLAY RECAP
server1.example.com   : ok=2  changed=1  unreachable=0  failed=0
server2.example.com   : ok=2  changed=1  unreachable=0  failed=0
server3.example.com   : ok=2  changed=1  unreachable=0  failed=0
 

 




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 0f2d84 in the box below so that we can be sure you are a human.