0

This is my ansible playbook call

playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
stats = callbacks.AggregateStats()
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
pb = PlayBook(
    playbook=ANS_PLAYBOOK,
    host_list=ANS_INVENTORY,
    callbacks = playbook_cb,
    runner_callbacks = runner_cb,
    stats = runner_cb
)
results = pb.run()
return results

and the output that i currently get is

{'device': {'unreachable': 0, 'skipped': 7, 'ok': 9, 'changed': 8, 'failures': 0}}

That's fairly OK, but i want to get the task-specific stats so that if something fails I can see what and where.

Kreet.
  • 151
  • 7

1 Answers1

0

I tried to implement python CLI that used the ansible python bindings. I failed because they have change classes, options and import hierarchy between minor versions.

The best source for find an answer for your question is to look inside appropriate ansible-playbook binary (every new version is different) and try to find the calls that you should use.

PS: This is my question with ansible 1.5.4 api How to set vars into ansible inventory? and what you need at t['failures'] colorize('failed', t['failures'], None)),

Also you should check if there is something helpful inside my next code sniplet: How to get all tasks of ansible playbook limit to ansible_os_family?

Community
  • 1
  • 1
Valeriy Solovyov
  • 5,384
  • 3
  • 27
  • 45