How to print out elapsed time using pause in ansible playbook

Viewed 163

I'm using a pause command in my playbook that pauses for 10 minutes while EC2 instances are built in AWS. I would like to see the elapsed time during the 10 minutes instead of guessing when the pause started. I see that stdout is an output of the pause command but I can't seem to get ansible to print stdout while the pause is pausing.

- name: Wait 10 minutes for the infra machines to be built in AWS
  pause:
    minutes: 10


Output:
TASK [machinesets : Wait 10 minutes for the infra machines to be built in AWS] ********************************************
Pausing for 600 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
1 Answers

I don't think the pause module prints out the progress as it waits. You could instead add a print right before the pause. Something like:

- name: Print datetime before pause
  run_once: true
  debug:
    msg: "{{ lookup('pipe', 'date') }}"

- name: Wait 10 minutes for the infra machines to be built in AWS
  pause:
    minutes: 10
Related