Reduce output of ansible-playbook command

6,004 views
Skip to first unread message

Roland Müller

unread,
Jul 3, 2021, 10:12:20 AM7/3/21
to Ansible Project
Hello,

is there some option to make ansible-playbook "quiet" about its own output and print only the explicit debug msg in line #17 . I tried to 'use no_log: True' both on task and tasks level but it suppresses all output.

Thanks in advance & BR,
Roland

ansible-playbook reduce_output.yaml

...
ok: [localhost] => (item={'path': '/tmp/.X11-unix/X0', 'mode': '0777', 'isdir': False, 'ischr': False, 'isblk': False, 'isreg': False, 'isfifo': False, 'islnk': False, 'issock': True, 'uid': 0, 'gid': 0, 'size': 0, 'inode': 38, 'dev': 37, 'nlink': 1, 'atime': 1625305628.0993037, 'mtime': 1625305628.0993037, 'ctime': 1625305628.0993037, 'gr_name': 'root', 'pw_name': 'root', 'wusr': True, 'rusr': True, 'xusr': True, 'wgrp': True, 'rgrp': True, 'xgrp': True, 'woth': True, 'roth': True, 'xoth': True, 'isuid': False, 'isgid': False}) => {
    "msg": "* FILE: /tmp/.X11-unix/X0"
}

  1 ---
  2 - name: 'playbook debugging output from find'
  3   hosts: localhost
  4   gather_facts: no
  5   ##no_log: True  ##kills all output :-(
  6  
  7   tasks:
  8   - name: find /tmp
  9     find:
 10       path: /tmp/
 11       file_type: any # default: file
 12       recurse: yes # default false
 13     register: out
 14  
 15   - name: list files line by line
 16     debug:
 17       msg: "* FILE: {{ item.path }}"
 18     with_items:
 19       - "{{ out.files }}"

Stefan Hornburg (Racke)

unread,
Jul 3, 2021, 11:02:25 AM7/3/21
to ansible...@googlegroups.com
On 03/07/2021 16:12, Roland Müller wrote:
> Hello,
>
> is there some option to make ansible-playbook "quiet" about its own output and print only the explicit debug msg in line #17 . I tried to 'use no_log: True' both on task and tasks level but it suppresses all output.
>
> Thanks in advance & BR,
> Roland
>

Hello Roland,

did you try "no_log: False" specifically for the debug task?

Regards
Racke

> ansible-playbook reduce_output.yaml
>
> ...
> ok: [localhost] => (item={'path': '/tmp/.X11-unix/X0', 'mode': '0777', 'isdir': False, 'ischr': False, 'isblk': False, 'isreg': False, 'isfifo': False, 'islnk': False, 'issock': True, 'uid': 0, 'gid': 0, 'size': 0, 'inode': 38, 'dev': 37, 'nlink': 1, 'atime': 1625305628.0993037, 'mtime': 1625305628.0993037, 'ctime': 1625305628.0993037, 'gr_name': 'root', 'pw_name': 'root', 'wusr': True, 'rusr': True, 'xusr': True, 'wgrp': True, 'rgrp': True, 'xgrp': True, 'woth': True, 'roth': True, 'xoth': True, 'isuid': False, 'isgid': False}) => {
>     "msg": "* FILE: /tmp/.X11-unix/X0"
> }
>
>   1 ---
>   2 - name: 'playbook debugging output from find'
>   3   hosts: localhost
>   4   gather_facts: no
>   5   ##no_log: True  ##kills all output :-(
>   6
>   7   tasks:
>   8   - name: find /tmp
>   9     find:
>  10       path: /tmp/
>  11       file_type: any # default: file
>  12       recurse: yes # default false
>  13     register: out
>  14
>  15   - name: list files line by line
>  16     debug:
>  17       msg: "* FILE: {{ item.path }}"
>  18     with_items:
>  19       - "{{ out.files }}"
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bf335b8f-efa9-44c1-bf8a-f7b959f18800n%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/bf335b8f-efa9-44c1-bf8a-f7b959f18800n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

Roland Müller

unread,
Jul 4, 2021, 3:12:32 AM7/4/21
to Ansible Project
brae...@gmail.com schrieb am Samstag, 3. Juli 2021 um 18:02:25 UTC+3:
On 03/07/2021 16:12, Roland Müller wrote:
> Hello,
>
> is there some option to make ansible-playbook "quiet" about its own output and print only the explicit debug msg in line #17 . I tried to 'use no_log: True' both on task and tasks level but it suppresses all output.
>
> Thanks in advance & BR,
> Roland
>

Hello Roland,

did you try "no_log: False" specifically for the debug task?

Regards
Racke

Hello Racke,

yes, I did that too (as I mentioned in my previous message): It has following consequence. Thus, all debug output is suppressed and an item=None line is printed for every finding of find task.

...
TASK [list files line by line] ******************************************************************************************
ok: [localhost] => (item=None)
ok: [localhost] => (item=None)
ok: [localhost] => (item=None)
...

BR,
Roland

Erik Godding Boye

unread,
Jul 4, 2021, 10:03:40 AM7/4/21
to ansible...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3d96fdcc-c78d-4d35-9d7f-0f833e3d8a80n%40googlegroups.com.

Roland Müller

unread,
Jul 4, 2021, 3:53:12 PM7/4/21
to ansible...@googlegroups.com

Hello Eric,


On 7/4/21 5:03 PM, Erik Godding Boye wrote:

Thank you very much! This works perfectly.


  1 ---
  2 - name: 'playbook debugging output from find'
  3   hosts: localhost
  4   gather_facts: no
  5 

  6   tasks:
  7   - name: find /tmp
  8     find:
  9       path: /tmp
 10       file_type: any # default: file
 11       recurse: yes # default false
 12     register: out
 13 
 14   - name: list files line by line
 15     debug:
 16       msg: "FILE: {{ item.path }}  isreg: {{ item.isreg }} isdir: {{ item.isdir }}"
 17     with_items:
 18       - "{{ out.files }}"
 19     loop_control:
 20       label: "{{ item.path }}"                                                                                      


Output snippet:

...

TASK [find /tmp] ********************************************************************************************************
ok: [localhost]



TASK [list files line by line] ******************************************************************************************

ok: [localhost] => (item=/tmp/OSL_PIPE_1000_SingleOfficeIPC_9eb5d83c64fa8a7cb259953b1032) => {
    "msg": "FILE: /tmp/OSL_PIPE_1000_SingleOfficeIPC_9eb5d83c64fa8a7cb259953b1032  isreg: False isdir: False"
}
ok: [localhost] => (item=/tmp/ansible_find_payload_pk8ljuwy) => {
    "msg": "FILE: /tmp/ansible_find_payload_pk8ljuwy  isreg: False isdir: True"
...

BR,

Roland


You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/TVgt8sLly0I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CALfBRgFmHptDH48qDBSZ%3Dnqs3V-tRMrDsLAZRq5DR%2B9hJtV3Gw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages