ansible.runner ask-pass?

41 views
Skip to first unread message

Michael Bogucki

unread,
Oct 13, 2015, 3:29:52 PM10/13/15
to Ansible Project
Hi Everyone,

I'm attempting to use the ansible api to query a bunch of servers (programmatically) .

I'm running into an issue where all of my servers require a MFA-authentication+passcode.

Is there a way I can have my python/ansible script prompt me for the password?
Obviously in a playbook or commandline call I can do an --ask-pass; however I need to leverage python for a bunch of
'other' processing tasks.

I'm using this basic code as a starter: (lifted from the ansible api docs/examples)

### ansible_hosts

[testservers]
vmdsxwo83
vmdsxwo84
vmdsxwo85
vmdsxwo86
vmdsxwo87



### test.py

#!/usr/local/bin/python

import ansible.runner

runner
= ansible.runner.Runner(
   module_name
='command',
   module_args
='uptime',
   pattern
='testservers',
   forks
=10
)

datastructure
= runner.run()
print datastructure



Thanks.

--mike
Reply all
Reply to author
Forward
0 new messages