Search

Top 60 Oracle Blogs

Recent comments

Ansible tips’n’tricks: even more output options

In my last post I wrote about the “debug” option to format Ansible output differently. I came across this setting simply by searching the usual developer forums for an alternative Ansible output option.

Having found out about the “debug” option made me curious, especially since there wasn’t an awful lot of documentation available about additional alternatives. Or so It thought before writing this post, there is actually, as you will see later. So to recap what I had so far: I noticed “skippy” in my distribution’s /etc/ansible/ansible.cfg although it is commented out. And I found the “debug” option via my favourite search engine, and there is the “default” as well.

There surely had to be more …

This wasn’t quite good enough for me and I started to wonder if there were more of these callbacks. Here is my Ansible version in case some of these callbacks might be quite recent:

[martin@controller environment]$ ansible --version | head -n 1
ansible 2.6.4

My first idea was to perform a file system search using find – I assumed trying to look out for “debug” or “default” would result in too many irrelevant hits, but “skippy” sounded unique enough a search term.

$ find / -iname "*skippy*" 2> /dev/null
/usr/lib/python2.7/site-packages/ansible/plugins/callback/skippy.py
/usr/lib/python2.7/site-packages/ansible/plugins/callback/skippy.pyc
/usr/lib/python2.7/site-packages/ansible/plugins/callback/skippy.pyo
[martin@linuxdev ~]$ 

This looks like a hit! I opened the first file, skippy.py, and found a documentation section:

DOCUMENTATION = '''
    callback: skippy
    callback_type: stdout
    requirements:
      - set as main display callback
    short_description: Ansible screen output that ignores skipped status
    version_added: "2.0"
    extends_documentation_fragment:
      - default_callback
    description:
        - This callback does the same as the default except it does not output skipped host/task/item status

So there you go, more information about the purpose of this callback! Are there any others that might be useful candidates for stdout_callback? Possibly! Let’s see (still in the callback directory)…

$ grep -i 'type: stdout' *.py
actionable.py:    type: stdout
debug.py:    type: stdout
default.py:    type: stdout
dense.py:type: stdout
full_skip.py:    type: stdout
json.py:    type: stdout
minimal.py:    type: stdout
null.py:    callback_type: stdout
oneline.py:    type: stdout
selective.py:    callback_type: stdout
skippy.py:    callback_type: stdout
stderr.py:    callback_type: stdout
unixy.py:    type: stdout
yaml.py:    type: stdout

Having unearthed this list I eventually found the relevant part of the documentation set! So instead of showing you the DOCUMENTATION variable for each of these callbacks, I point you to the official Ansible 2.6 documentation:

https://docs.ansible.com/ansible/2.6/plugins/callback.html#plugin-list

Happy scripting!