Skip to content
ohsudo, Home
Infrastructure as Code

Ansible "couldn't resolve module/action": install the collection, or fix the name

Fix Ansible "couldn't resolve module/action": install the missing collection, use the full module name, and check the Python environment.

Beginner3 min readApplies to ansible-core 2.15+ · Ansible 9+ · ansible-galaxy

by OhSudo ·

Checked on real software: Ansible · November 2026How we check

[ERROR]: couldn't resolve module/action 'community.docker.docker_container'. This often indicates a misspelling, missing collection, or incorrect module path.
Origin: /home/deploy/site/playbook.yml:4:7

Older versions of ansible-core start it with ERROR!, and have no Origin line, which here points to the task’s line and column. The message lists the three causes, and the first one is by far the most common now: the module lives in a collection that isn’t installed.

Since Ansible 2.10, most modules moved out of Ansible itself, into collections. The name before the last dot, here community.docker, is the collection. If you installed ansible-core alone, only the built-in ansible.builtin modules are there.

TL;DR

Terminal window
ansible-galaxy collection list community.docker
ansible-galaxy collection install community.docker

Then run the playbook again. For a team, list collections in requirements.yml: section 3.

1. Is the collection there?

Terminal window
ansible-galaxy collection list
ansible-galaxy collection list community.docker

If it’s not listed, install it:

Terminal window
ansible-galaxy collection install community.docker

Check what you have installed, too:

Terminal window
ansible --version
pip show ansible ansible-core 2>/dev/null | grep -E '^(Name|Version)'

The ansible package includes many popular collections, community.docker among them. The ansible-core package doesn’t. Installing just ansible-core is fine, as long as you add the collections you use.

2. Is the name right?

Since collections, modules have full names, called FQCNs:

Old short name Full name
docker_container community.docker.docker_container
mysql_user community.mysql.mysql_user
postgresql_db community.postgresql.postgresql_db
firewalld ansible.posix.firewalld
win_service ansible.windows.win_service
copy, template, apt ansible.builtin.copy, and so on

Look up a module’s real name, which also confirms it’s installed:

Terminal window
ansible-doc -l | grep docker_container
ansible-doc community.docker.docker_container

A typo in any part of the name gives the same error. So does a module that was removed: very old playbooks may use names that no longer exist in any collection. ansible-doc and the collection’s documentation give the replacement.

A YAML mistake can also look like this. If a task’s keys are indented wrongly, Ansible may read an option, like name:, as the module. If the “module” in the message is a word like name, check the task’s indentation, and see mapping values are not allowed.

3. Make it repeatable: requirements.yml

So that every machine and pipeline has the same collections, list them in the project:

collections/requirements.yml
collections:
- name: community.docker
version: ">=4.0.0"
- name: ansible.posix
Terminal window
ansible-galaxy collection install -r collections/requirements.yml

Run that in CI before the playbook.

4. Installed, and still not found

Then Ansible is looking somewhere else:

  • Another Python environment. ansible-playbook from one virtual environment, collections installed by another. Compare which ansible-playbook with which ansible-galaxy, and look at the ansible collection location line in ansible --version.
  • A collections path in ansible.cfg, with collections_path, or ANSIBLE_COLLECTIONS_PATH set, that doesn’t include where you installed. ansible-config dump --only-changed shows settings that differ from the default.
  • sudo: collections installed for your user are in ~/.ansible/collections, which root doesn’t see. Don’t run ansible-galaxy with sudo for your own playbooks.

Warning

Pin collection versions in requirements.yml for anything that runs in production. A new major version of a collection can change modules’ options, and a playbook that worked yesterday then fails, or does something different, after a fresh install.

Shell, we have a problem!

Similar, but different: UNREACHABLE! Failed to connect to the host means Ansible can’t reach the machine at all. Missing sudo password means it connected and can’t become root. couldn't resolve module/action 'docker_container', with a short name, is this same problem: install the collection, and use the full name. YAML errors are in mapping values are not allowed. For everyday commands, see the Ansible cheat sheet.

Found this useful? Share it.

Found a mistake? Let us know at contact@ohsudo.com.

Articles

Related articles