How to avoid showing skipped Ansible tasks

ansible

The output of my playbooks are always completely swamped with useless output regarding which tasks have been skipped, which makes it annoying and time consuming to go through and find specific information I'm looking for.

Here's an example of a playbook

- name: Stopping Puppet Agent
  service: name=pe-puppet state=stopped
  ignore_errors: true
  register: result
- include: rollback/restart-pe-puppet.yml
  when: result|failed

And the associated output:

TASK: [name | Stopping Puppet Agent] **************************************
<server.name> REMOTE_MODULE service name=pe-puppet state=stopped
changed: [server.name] => {"changed": true, "name": "pe-puppet",     "state":"stopped"}

TASK: [name | judge_log msg='Restarting pe-puppet'] ***********************
skipping: [server.name]

TASK: [name | starting pe-puppet] *****************************************
skipping: [server.name]

TASK: [name | judge_log msg='pe-puppet restart successful'] ***************
skipping: [sserver.name]

TASK: [name | judge_log msg='pe-puppet restart failed' sec=FATAL] *********
skipping: [server.name]

TASK: [name | fail msg="Failed to start pe-puppet."] **********************
skipping: [server.name]

TASK: [name | judge_log msg='{{APP_NAME | capitalize}} deployment failed.'] ***
skipping: [server.name]

TASK: [name | fail msg="The {{APP_NAME | capitalize}} deployment failed."] ***
skipping: [server.name]

Almost all of that output is useless to me. The display_skipped_hosts says it still causes the task header to appear. Is there any way to omit skipped tasks completely?

Best Answer

I use another way without changing any code:

Ansible use 'default' callback plugin to display output, but you can use 'skippy' callback plugin instead of 'default'. 'skippy' use 'default' except for skipped tasks.

To use 'skipped' plugin, add following line (or uncomment it) in your ansible.cfg file:

stdout_callback = skippy

To localize you ansible.cfg, use command:

ansible --version

If you don't have this file, get example file from ansible sources and copy it in your working folder from where you call ansible.