In my post ‘do not display skipping task in ansible‘, I mentioned that the stdout_callback = full_skip configuration can suppress the skipping task names in the ansible console output. However, after I upgrade ansible to 2.7.6, I find that there are duplicated task names in ansible console output.
Take the below ansible configuration and playbook for example
ansible.cfg
[defaults] host_key_checking=False gathering=explicit remote_user=root stdout_callback=full_skip
demo.yml
--- - name: demo play hosts: localhost remote_user: root any_errors_fatal: True tasks: - name: demo task shell: echo demo task
when I run the below command, I get the below result:
ansible-playbook -c paramiko demo.yml [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' PLAY [demo play] ****************************************************************************************************** TASK [demo task] ****************************************************************************************************** TASK [demo task] ****************************************************************************************************** changed: [localhost] PLAY RECAP ************************************************************************************************************ localhost : ok=1 changed=1 unreachable=0 failed=0
There are duplicated task names ‘demo task’ in the console output. This seems to be a bug for full_skip callback plugin.
However, after I read the documentation for ansible 2.7, I find that the full_skip plugin has been deprecated and will be removed in ansible 2.11. The default callback plugin now support suppressing the skipping task name in the console output.
To suppress skipping task names, use ‘display_skipped_hosts = no‘ in the ansible configuration file. Take the below for example:
ansible.cfg
[defaults] host_key_checking=False gathering=explicit remote_user=root display_skipped_hosts = no
demo.yml
--- - name: demo play hosts: localhost remote_user: root any_errors_fatal: True tasks: - name: demo task shell: echo demo task - name: demo play 2 hosts: localhost remote_user: root any_errors_fatal: True tasks: - name: demo task 2 shell: echo demo task 2 when: cond is defined and cond == 'task2'
The ansible-playbook output is as below, just as what we expected. There is no skipping task name in the console output.
ansible-playbook -c paramiko demo.yml [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' PLAY [demo play] *************************************************************** TASK [demo task] *************************************************************** changed: [localhost] PLAY [demo play 2] ************************************************************* PLAY RECAP ********************************************************************* localhost : ok=1 changed=1 unreachable=0 failed=0