Skip to content

Commit 166eac9

Browse files
jrosdahlphilpep
authored andcommitted
Handle ansible_connection type community.docker.docker
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.
1 parent 425ec44 commit 166eac9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

test/test_backends.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ def get_vars(host):
283283
"user": None,
284284
},
285285
),
286+
(
287+
{},
288+
b"host ansible_connection=community.docker.docker",
289+
{
290+
"NAME": "docker",
291+
"name": "host",
292+
"user": None,
293+
},
294+
),
286295
(
287296
{},
288297
b"host ansible_connection=docker ansible_become=yes ansible_become_user=u ansible_user=z ansible_host=container",

testinfra/utils/ansible_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ def get_ansible_host(config, inventory, host, ssh_config=None, ssh_identity_file
6868
"paramiko_ssh",
6969
"local",
7070
"docker",
71+
"community.docker.docker",
7172
"lxc",
7273
"lxd",
7374
):
7475
# unhandled connection type, must use force_ansible=True
7576
return None
7677
connection = {
78+
"community.docker.docker": "docker",
7779
"lxd": "lxc",
7880
"paramiko_ssh": "paramiko",
7981
"smart": "ssh",

0 commit comments

Comments
 (0)