# How do I reduce the debug output to just the message with this playbook ?

**URL:** <https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887>\
**Category:** Ansible Project\
**Created:** [July 27, 2019, 5:34pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887 "2019-07-27T17:34:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan\_prihoda](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@ryan\_prihoda](https://forum.ansible.com/u/ryan_prihoda)\
**Post date:** [July 27, 2019, 5:34pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/1 "2019-07-27T17:34:27Z")

</div>

`

### catalina-inspect.yml

- name: find tomcat logs size  
hosts: tomcat  
become: no  
tasks:

- name: finding files task  
find:  
path: .  
file\_type: directory  
patterns: “tomcat-\*”  
register: find  
changed\_when: False

- name: size  
shell: du -h “{{ item }}/logs” | awk ‘{print $1}’  
loop: “{{ find.files |map(attribute=‘path’)|list }}”  
register: size

- debug:  
msg: “{{ item.item }}/logs = {{ item.stdout }}”  
loop: “{{ size.results }}”  
`

Is there a better way to handle the debug output so that I am only seeing the msg portion ?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 27, 2019, 6:10pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/2 "2019-07-27T18:10:26Z")

</div>

Ansible is not a reporting tool, so if that is what you are looking for you probably need some other tool.  
That being said you have many callback plugins to choose[1] and if non of them suites your need to can always create you own.

[1] [https://docs.ansible.com/ansible/2.7/plugins/callback.html#plugin-list](https://docs.ansible.com/ansible/2.7/plugins/callback.html#plugin-list)

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 27, 2019, 8:22pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/3 "2019-07-27T20:22:33Z")

</div>

Yes: [https://docs.ansible.com/ansible/latest/plugins/callback/default.html](https://docs.ansible.com/ansible/latest/plugins/callback/default.html)

---

<div class="post-metadata">

**Author:** ![ryan\_prihoda](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@ryan\_prihoda](https://forum.ansible.com/u/ryan_prihoda)\
**Post date:** [July 27, 2019, 8:37pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/4 "2019-07-27T20:37:53Z")

</div>

Apparently I couldn’t delete my comment fast enough. Thanks guys.

Ultimately the output doesn’t matter as this is just a single task in a much larger play, but I was just curious what the standard practices are and how to manipulate the output.

---

<div class="post-metadata">

**Author:** ![ryan\_prihoda](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@ryan\_prihoda](https://forum.ansible.com/u/ryan_prihoda)\
**Post date:** [July 28, 2019, 12:55pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/5 "2019-07-28T12:55:55Z")

</div>

`

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [as2] =\> (item={‘\_ansible\_parsed’: True, ‘stderr\_lines’: , u’changed’: True, u’stdout’: u’189G’, ‘\_ansible\_item\_result’: True, u’delta’: u’0:00:00.014604’, ‘stdout\_lines’: [u’189G’], ’  
\_ansible\_item\_label’: u’tomcat-as2’, u’end’: u’2019-07-27 12:33:45.592563’, ‘\_ansible\_no\_log’: False, ‘failed’: False, u’cmd’: u’du -h “tomcat-as2/logs” | awk '{print $1}'‘, ‘item’: u’tomc  
at-as2’, u’stderr’: u’‘, u’rc’: 0, u’invocation’: {u’module\_args’: {u’warn’: True, u’executable’: None, u’\_uses\_shell’: True, u’\_raw\_params’: u’du -h “tomcat-as2/logs” | awk '{print $1}'‘,  
u’removes’: None, u’argv’: None, u’creates’: None, u’chdir’: None, u’stdin’: None}}, u’start’: u’2019-07-27 12:33:45.577959’, ‘\_ansible\_ignore\_errors’: None}) =\> {  
“msg”: “tomcat-as2/logs = 189G”  
}  
ok: [as2] =\> (item={‘\_ansible\_parsed’: True, ‘stderr\_lines’: , u’changed’: True, u’stdout’: u’31G’, ‘\_ansible\_item\_result’: True, u’delta’: u’0:00:00.016055’, ‘stdout\_lines’: [u’31G’], ‘\_a  
nsible\_item\_label’: u’tomcat-gw2’, u’end’: u’2019-07-27 12:33:45.961107’, ‘\_ansible\_no\_log’: False, ‘failed’: False, u’cmd’: u’du -h “tomcat-gw2/logs” | awk '{print $1}'‘, ‘item’: u’tomcat  
-gw2’, u’stderr’: u’‘, u’rc’: 0, u’invocation’: {u’module\_args’: {u’warn’: True, u’executable’: None, u’\_uses\_shell’: True, u’\_raw\_params’: u’du -h “tomcat-gw2/logs” | awk '{print $1}'‘, u  
‘removes’: None, u’argv’: None, u’creates’: None, u’chdir’: None, u’stdin’: None}}, u’start’: u’2019-07-27 12:33:45.945052’, ‘\_ansible\_ignore\_errors’: None}) =\> {  
“msg”: “tomcat-gw2/logs = 31G”  
}  
ok: [as2] =\> (item={‘\_ansible\_parsed’: True, ‘stderr\_lines’: , u’changed’: True, u’stdout’: u’2.3G’, ‘\_ansible\_item\_result’: True, u’delta’: u’0:00:00.013730’, ‘stdout\_lines’: [u’2.3G’], ’  
\_ansible\_item\_label’: u’tomcat-staging’, u’end’: u’2019-07-27 12:33:46.283170’, ‘\_ansible\_no\_log’: False, ‘failed’: False, u’cmd’: u’du -h “tomcat-staging/logs” | awk '{print $1}'‘, ‘item’  
: u’tomcat-staging’, u’stderr’: u’‘, u’rc’: 0, u’invocation’: {u’module\_args’: {u’warn’: True, u’executable’: None, u’\_uses\_shell’: True, u’\_raw\_params’: u’du -h “tomcat-staging/logs” | awk  
'{print $1}'‘, u’removes’: None, u’argv’: None, u’creates’: None, u’chdir’: None, u’stdin’: None}}, u’start’: u’2019-07-27 12:33:46.269440’, ‘\_ansible\_ignore\_errors’: None}) =\> {  
“msg”: “tomcat-staging/logs = 2.3G”  
}  
ok: [as2] =\> (item={‘\_ansible\_parsed’: True, ‘stderr\_lines’: , u’changed’: True, u’stdout’: u’131G’, ‘\_ansible\_item\_result’: True, u’delta’: u’0:00:00.013226’, ‘stdout\_lines’: [u’131G’], ’  
\_ansible\_item\_label’: u’tomcat-as7’, u’end’: u’2019-07-27 12:33:46.656400’, ‘\_ansible\_no\_log’: False, ‘failed’: False, u’cmd’: u’du -h “tomcat-as7/logs” | awk '{print $1}'‘, ‘item’: u’tomc  
at-as7’, u’stderr’: u’‘, u’rc’: 0, u’invocation’: {u’module\_args’: {u’warn’: True, u’executable’: None, u’\_uses\_shell’: True, u’\_raw\_params’: u’du -h “tomcat-as7/logs” | awk '{print $1}'‘,  
u’removes’: None, u’argv’: None, u’creates’: None, u’chdir’: None, u’stdin’: None}}, u’start’: u’2019-07-27 12:33:46.643174’, ‘\_ansible\_ignore\_errors’: None}) =\> {  
“msg”: “tomcat-as7/logs = 131G”  
}

`

Tried some callback plugins. Doesn’t really work. I swear I’ve done this before, but I admittedly have not touched ansible in a while. Would filtering the loop in the the debug task in some way do what I need ?

---

<div class="post-metadata">

**Author:** ![Andrew\_Feller](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@Andrew\_Feller](https://forum.ansible.com/u/Andrew_Feller)\
**Post date:** [July 28, 2019, 1:59pm UTC](https://forum.ansible.com/t/how-do-i-reduce-the-debug-output-to-just-the-message-with-this-playbook/30887/6 "2019-07-28T13:59:27Z")

</div>

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_loops.html#limiting-loop-output-with-label](https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#limiting-loop-output-with-label)
