Python ansible playbook and output

Hello,
I write playbook and python code to run it.Code i took from ansible-playbook as example:

playbook=params[“playbook”]
inventory=ansible.inventory.Inventory(hosts)
inventory.set_playbook_basedir(os.path.dirname(playbook))

stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)

params[“inventory”]=inventory
params[“stats”]=stats
params[“callbacks”]=playbook_cb
params[“runner_callbacks”]=runner_cb

pb=ansible.playbook.PlayBook(**playbook_params)

pr=pb.run()

But I got:

TASK: [base | Install packages] ***********************************************
ok: [127.0.0.1] => (item=build-essential) => {
“item”: “build-essential”,
“msg”: “install build-essential state=present update_cache=yes cache_valid_time=86400”
}

I want run playbooks without output. How to do this?

Regards.

Did you ever figure out how to achieve this?

I have the same ‘challenge’.

You need to replace the Callback classes with your own that don’t do anything. I believe 1 of the classes in use inherits from a default that performs no actions. The other, I think you have to create yourself.