Interview Prep/Ansible/Roles, Collections and Galaxy

How does Ansible find collections, and what is the `collections` keyword?

IntermediateConceptRoles, Collections and Galaxy
Answer

Collections are searched in collections_path (ANSIBLE_COLLECTIONS_PATH), which defaults to ~/.ansible/collections and /usr/share/ansible/collections, plus a collections/ directory adjacent to the playbook (collections/ansible_collections/<ns>/<name>).

The play keyword collections: adds namespaces to the lookup so short names resolve:

- hosts: all
  collections:
    - community.docker
  tasks:
    - docker_container: { name: web, image: nginx }

This is discouraged. FQCNs avoid ambiguity.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Galaxy