15

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?

  • If you happy with editing the ansible code, you can try to add line msg = '' before this line – masegaloeh Feb 5 '15 at 22:08
13

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.

| improve this answer | |
4

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.

| improve this answer | |
  • Is it possible to apply this option in the playbook? – Ashark Mar 22 at 1:01
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)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.