You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an attempt to demystify the callback modules so if you wish to make a new callback module or a change to an existing one.
When I started with callback modules I was frustrated with the lack of documentation in regards to what the methods do, and how they affect the output of ansible, so this is an attempt to clarify that for those who wish to change callback modules.
Methods for Ansible Callback class
The following code snippet returns all of the methods of the Callback Class
These call also be found in init.py in the callback folder
from ansible.plugins.callback import CallbackBase
for name,obj in CallbackBase.__dict__.iteritems() :
print '%-25s --> %r' % (name, obj)
Methods and initial state
Without a callback module this is is the initial state of each method, and the primary relevant actions of those methods.
Runner methods
v2 items
v1 items
initial defaults v2
initial defaults v1
v2_runner_item_on_failed
pass
v2_runner_item_on_ok
pass
v2_runner_item_on_skipped
pass
v2_runner_on_async_failed
runner_on_async_failed
Sets var host, job_id
pass
v2_runner_on_async_ok
runner_on_async_ok
Sets var host, job_id
pass
v2_runner_on_async_poll
runner_on_async_poll
Sets var host, job_id, clock
pass
v2_runner_on_failed
runner_on_failed
Sets var host
pass
v2_runner_on_file_diff
pass
v2_runner_on_no_hosts
runner_on_no_hosts
pass
pass
v2_runner_on_ok
runner_on_ok
Sets var host
pass
v2_runner_on_skipped
runner_on_skipped
if showing skipped show skipped host
pass
v2_runner_on_unreachable
runner_on_unreachable
Sets var host
pass
v2_runner_retry
pass
Playbooks methods
v2 items
v1 items
initial defaults v2
initial defaults v1
v2_playbook_on_cleanup_task_start
pass
v2_playbook_on_handler_task_start
pass
v2_playbook_on_import_for_host
playbook_on_import_for_host
Sets var host
pass
v2_playbook_on_include
pass
v2_playbook_on_no_hosts_matched
playbook_on_no_hosts_matched
pass
pass
v2_playbook_on_no_hosts_remaining
playbook_on_no_hosts_remaining
pass
pass
v2_playbook_on_not_import_for_host
playbook_on_not_import_for_host
Sets var host
pass
v2_playbook_on_notify
playbook_on_notify
Sets var host
pass
v2_playbook_on_play_start
playbook_on_play_start
pass
pass
v2_playbook_on_setup
playbook_on_setup
pass
pass
v2_playbook_on_start
playbook_on_start
pass
pass
v2_playbook_on_stats
playbook_on_stats
pass
pass
v2_playbook_on_task_start
playbook_on_task_start
pass
pass
v2_playbook_on_vars_prompt
playbook_on_vars_prompt
pass
pass
Misc methods
v2 items
v1 items
initial defaults v2
initial defaults v1
_init_
sets options, display, etc
_clean_results
removes data from results for display
_dump_results
indents results, Removes base keys, exepction. Removes invocation and diff in result when less than level 3 verbosity. Returns json
_get_diff
Returns differences
_get_item
Sets var item
_handle_exception
Displays exeption occured, and if Verbosity 3 shows traceback
_handle_warnings
Displays 'warnings and depreciations
_process_items
Del items, now handeled by individual callbacks
v2_on_any
on_any
pass
pass
v2_on_file_diff
on_file_diff
Sets var host
pass
set_options
Sets options, default is none
set_play_context
pass
Within default Callback module only
_print_task_banner
Default Callback Module
The methods called in the default callback module and what they do.