Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit e5a5171

Browse files
authored
fix: specify docker modules namespace (#56)
Running in an ansible-core project, I get this failure while running a molecule test with the docker driver: ``` INFO Running default > destroy ERROR! couldn't resolve module/action 'docker_container'. This often indicates a misspelling, missing collection, or incorrect module path. The error appears to be in '/var/home/yajo/mydevel/mando/.venv/lib/python3.9/site-packages/molecule_docker/playbooks/destroy.yml': line 8, column 7, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: tasks: - name: Destroy molecule instance(s) ^ here ``` After fixing the playbooks, it still fails with: ``` PLAY [prepare] ***************************************************************** TASK [Gathering Facts] ********************************************************* fatal: [basic]: FAILED! => {"msg": "the connection plugin 'docker' was not found"} ``` So, here are the fixes.
1 parent 7eaf9df commit e5a5171

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

molecule_docker/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def login_options(self, instance_name):
218218
return {"instance": instance_name}
219219

220220
def ansible_connection_options(self, instance_name):
221-
x = {"ansible_connection": "docker"}
221+
x = {"ansible_connection": "community.docker.docker"}
222222
if "DOCKER_HOST" in os.environ:
223223
x["ansible_docker_extra_args"] = "-H={}".format(os.environ["DOCKER_HOST"])
224224
return x

molecule_docker/playbooks/create.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
vars:
88
molecule_labels:
99
owner: molecule
10+
collections:
11+
- community.docker
1012
tasks:
1113
- name: Log into a Docker registry
1214
docker_login:

molecule_docker/playbooks/destroy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
connection: local
55
gather_facts: false
66
no_log: "{{ molecule_no_log }}"
7+
collections:
8+
- community.docker
79
tasks:
810
- name: Destroy molecule instance(s)
911
docker_container:

molecule_docker/playbooks/validate-dockerfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
- hosts: localhost
44
connection: local
55
gather_facts: false
6+
collections:
7+
- community.docker
68
vars:
79
platforms:
810
# platforms supported as being managed by molecule/ansible, this does

0 commit comments

Comments
 (0)