pytest-dev / pytest-testinfra

Testinfra test your infrastructures
https://testinfra.readthedocs.io
Apache License 2.0
2.37k stars 355 forks source link

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

Open lmesz-bitrise opened 4 years ago

lmesz-bitrise commented 4 years ago

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.

urskog84 commented 2 years ago

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

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")
mshonichev commented 5 months ago

as of 2024, issue still reproduced. Ansible deprecates ansible_ssh_pass way long ago, maybe it's time to finally fix it?