Get result content of ansible.playbook Playbook in python

Hello,

I have a playbook.yml which outputs password, please see this task:

`

tasks:

  • name: get
    command: echo {{ test_password }}
    register: result

  • debug: var=result.stdout_lines

`

I run this playbook in python script:

`

def run_playbook():
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(
verbose=ansible.utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(
stats, verbose=ansible.utils.VERBOSITY)
pb = PlayBook(playbook=‘playbook.yml’,
stats=stats,
callbacks=playbook_cb,
runner_callbacks=runner_cb,
check=True,
vault_password=‘abcd’)
pb.run()

`

Print pb

returns an object, but I fail to figure out how to return the content of password so I can use it in the python script for the authentication.
Any ideas?

Thanks in advance,
Eve