Context
I have an Ansible playbook that includes a very long task, up to one hour.
Very simplified, it looks like:
- hosts: localhost
tasks:
- name: Short task
debug:
msg: "I'm quick!"
- name: Long task
shell: "sleep 15s"
When the user runs the playbook, the output is at first:
PLAY [localhost] ********************
TASK [Gathering Facts] **************
ok: [127.0.0.1]
TASK [Short task] *******************
ok: [127.0.0.1] => {
"msg": "I'm quick!"
}
(hang there until Long task is done)
TASK [Long task] ********************
changed: [127.0.0.1]
Problem
The end users of the playbook believe that there is a problem with Short task
since it hangs there, while it's Long task
that is causing the delay.
Question
How could I configure ansible or the playbook to print the headers defined in name:
before excuting the task?
What I what to achieve is an output like:
PLAY [localhost] ********************
TASK [Gathering Facts] **************
ok: [127.0.0.1]
TASK [Short task] *******************
ok: [127.0.0.1] => {
"msg": "I'm quick!"
}
TASK [Long task] ********************
(and hang there during the execution)
changed: [127.0.0.1]
ansible-playbook
from the terminal withansible-2.9.2
. I have the optionstdout_callback=skippy
in myansible.cfg
. I tried withstdout_callback=default
without success. I observed that ansible prints the header first in ad-hoc mode but not in playbook mode.stdout_callback
(default). I cannot reproduce your problem in either case. Double check you are not loading a config file withansible-playbook --version
in the directory where you are going to launch the playbook.ansible.cfg
. Settingdisplay_skipped_hosts=False
is the root cause of my problem.