Issue with ansible-runner

Hi all,

I’m having an issue with runner:

r = ansible_runner.run(inventory=“rubuntu”, playbook=“/home/ro/rubuntutest.yml”, passwords={“Password:\s*?$”: “pipo”})

it seems like I’m using passwords wrong since it doesn’t login in the machine to do stuff, if i launch the playbook manually and insert the password manually everything works.

How should i fix the password field?

Thanks in advance.

What do you mean by “doesn’t login”? Are you getting an error message back from ansible-playbook? Is runner hanging during the run? Is this supposed to be the SSH password or the BECOME password?

You generally need to supply a command line option to ansible-playbook to force it to prompt for the password (-k or -K, depending on your needs). There is a run() option for this named cmdline. And your password regex is probably not correct. Example:

r = ansible_runner.run(
    inventory="rubuntu",
    playbook="/home/ro/rubuntutest.yml",
    cmdline="-k",
    passwords={"SSH Password:\\s*?$": "my_password_here"}
)

The docs have some more examples and info, in case you haven’t seen it.

2 Likes