Print Ansible header before executing a long running task
Solution 1:
Migrating my comment to an answer upon OP's request
I am using Ansible 2.9.2.
I tried with no config file and with a config file with no value declared for stdout_callback
(default). I cannot reproduce your problem in either case.
This is my test playbook:
---
- hosts: localhost
gather_facts: false
tasks:
- name: Short running
debug:
msg: I'm a short task
- name: LOOOOOOOOOng task
shell: sleep 2000
And the result (in both cases. Note: interruption by user after task header display)
$ ansible-playbook /tmp/play.yml
PLAY [localhost] **************************************************************************************************************************************************************************************************
TASK [Short running] **********************************************************************************************************************************************************************************************
ok: [localhost] => {
"msg": "I'm a short task"
}
TASK [LOOOOOOOOOng task] ******************************************************************************************************************************************************************************************
^C [ERROR]: User interrupted execution
Double check which config file you are loading with ansible-playbook --version
in the directory where you are going to launch the playbook. I also suggest you try without any config file to see if it fixes your issue (and then see which setting is actually causing the issue).
Added from OP's comment: it turns out the problematic setting in ansible.cfg in this specific case was display_skipped_hosts=False
Solution 2:
The display_skipped_hosts=false
in /etc/ansible/ansible.cfg fixed it for me.
Is it a bug? I don't like to see the skipped hosts but do like to see the progress of my playbook.
Using Ansible 2.10.3