16

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?

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
asdoylejr
  • 281
  • 1
  • 2
  • 7
  • If you happy with editing the ansible code, you can try to add line `msg = ''` before [this line](https://github.com/ansible/ansible/blob/6d788629a277837191a54a2f900dfdd72b155ce7/lib/ansible/callbacks.py#L558) – masegaloeh Feb 05 '15 at 22:08

3 Answers3

14

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.

Nelson G.
  • 304
  • 2
  • 6
8

Now, the skippy module is deprecated.

Create ansible.cfg at the root of your project, and add the following instructions:

[defaults]
display_skipped_hosts = no

You can also edit your global configuration file /etc/ansible/ansible.cfg.

Mikael Flora
  • 181
  • 1
  • 2
2

If the documentation says the header was still appears, then you can't avoid it unless you change the ansible behaviour by edit the code. If you still insist to edit it, then you can try to find file lib/ansible/callbacks.py and add this line of string

msg = ''

before this line

display(msg, color='cyan', runner=self.runner)
masegaloeh
  • 18,236
  • 10
  • 57
  • 106