pytest-testinfra icon indicating copy to clipboard operation
pytest-testinfra copied to clipboard

ansible_runner doesn't accept ansible's user password via ansible_password variable

Open lmesz-bitrise opened this issue 4 years ago • 2 comments

When using testinfra with ansible_runner the only acceptable variable that can contain the password for ansible's user is ansible_ssh_pass. Based on ansible documentation if the user wants to use ansible with a password the ansible_password must be set. The reason why only ansible_ssh_pass is accepted is that the password parameter is directly pulled from ansible_ssh_pass. See code here I plan to create a PR to fix this if it is okay.

lmesz-bitrise avatar Nov 02 '20 08:11 lmesz-bitrise

Hi @lmesz-bitrise thanks for adding this issue. It took me a long time to find the solution to this. I have always used the ansible_password: variable name for my ansible inventorys..

Some google phrases i used

  • testinfra promts for password
  • testinfra ask for password
  • testinfra ansible promts for password

After looking around in the code, I think that the errors are here https://github.com/pytest-dev/pytest-testinfra/blob/master/testinfra/utils/ansible_runner.py#L148

Possibel solution to this issue

password = get_config("ansible_ssh_pass")
if password == None:
    password = get_config("ansible_password")

urskog84 avatar Aug 20 '22 20:08 urskog84