Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSHException with latest testinfra #2069

Closed
sassoo opened this issue May 28, 2019 · 6 comments · Fixed by #2078
Closed

SSHException with latest testinfra #2069

sassoo opened this issue May 28, 2019 · 6 comments · Fixed by #2078

Comments

@sassoo
Copy link

sassoo commented May 28, 2019

Issue Type

  • Bug report

Molecule and Ansible details

ansible 2.8.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/xxx/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Apr  9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
molecule, version 2.20.1

Molecule installation method (one of):

  • pip

Ansible installation method (one of):

  • pip

Desired Behavior

molecule verify with the vagrant driver using virtualbox should successfully ssh into the guest vm created by molecule. This worked before upgrading to latest molecule & testinfra without changing anything else.

Actual Behaviour

The error is: SSHException: No authentication methods available. If I change the molecule generated ansible inventory files ansible_private_key_file key to ansible_ssh_private_key_file it works. Additionally, molecule login works without issue. This worked before upgrading to latest molecule & testinfra without changing anything else.

Another workaround in a simple test file is:

import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
    os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_docker_run(host):
    current = host.backend.ansible_runner.inventory['_meta']['hostvars']['instance-1']['ansible_private_key_file']
    host.backend.ansible_runner.inventory['_meta']['hostvars']['instance-1']['ansible_ssh_private_key_file'] = current
    with host.sudo():
        assert host.run('docker run -t -d --name test alpine cat').rc == 0
        assert host.docker('test').is_running

I'm unsure if molecule or testinfra is at fault so posting here first. Let me know if I should post a testinfra issue.

@decentral1se
Copy link
Contributor

decentral1se commented May 28, 2019

Thanks for the report! AFAICT, both are still supported in Ansible:

I did take a look into testinfra and it seems to be making a decision on this:

So, it looks like we have a mismatch from testinfra then? We should perhaps try to patch testinfra to support both since Ansible advertises that as well. What do you think @sassoo?

@decentral1se
Copy link
Contributor

Took a stab in pytest-dev/pytest-testinfra#448.

@sassoo
Copy link
Author

sassoo commented May 28, 2019

I took a quick glance at the ansible documentation here & only saw a reference to ansible_ssh_private_key_file.

Also, many of the other ssh related keys include 'ssh' in the name so for consistency & easy googling I'd probably migrate toward that. If it's a PITA then no big deal but it was the absence of any google results for ansible_private_key_file that made me think to test changing it.

@sassoo
Copy link
Author

sassoo commented May 28, 2019

Also, thanks for the rapid feedback & testinfra issue! Super cool.

@decentral1se
Copy link
Contributor

Cool! Testinfra change is merged now so it's possible to test against latest Testinfra HEAD. I've asked for a release and will close this when that is officially on PyPi. Thanks again for this early testing and feedback.

@SergeyBear
Copy link

Please reopen #2077 - its not a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants