Get result content of ansible.playbook Playbook in python

33 views
Skip to first unread message

evela...@gmail.com

unread,
May 25, 2016, 10:22:03 AM5/25/16
to Ansible Project
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
Reply all
Reply to author
Forward
0 new messages