Skip to content

Commit

Permalink
Handle ansible_connection type community.docker.docker
Browse files Browse the repository at this point in the history
Molecule's Docker driver sets ansible_connection to
community.docker.docker, making
testinfra.utils.ansible_runner.AnsibleRunner.get_host fail to return
such a host in a Molecule test using the Docker driver.

Fix this by translating "community.docker.docker" to "docker".

Closes #648.
  • Loading branch information
jrosdahl authored and philpep committed Apr 12, 2022
1 parent 425ec44 commit 166eac9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ def get_vars(host):
"user": None,
},
),
(
{},
b"host ansible_connection=community.docker.docker",
{
"NAME": "docker",
"name": "host",
"user": None,
},
),
(
{},
b"host ansible_connection=docker ansible_become=yes ansible_become_user=u ansible_user=z ansible_host=container",
Expand Down
2 changes: 2 additions & 0 deletions testinfra/utils/ansible_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ def get_ansible_host(config, inventory, host, ssh_config=None, ssh_identity_file
"paramiko_ssh",
"local",
"docker",
"community.docker.docker",
"lxc",
"lxd",
):
# unhandled connection type, must use force_ansible=True
return None
connection = {
"community.docker.docker": "docker",
"lxd": "lxc",
"paramiko_ssh": "paramiko",
"smart": "ssh",
Expand Down

0 comments on commit 166eac9

Please sign in to comment.