Interview Prep/Ansible/Roles, Collections and Galaxy

What is the difference between a role and a collection?

IntermediateConceptRoles, Collections and Galaxy
Answer

A role is one reusable unit of tasks and variables. A collection is a packaging format that can contain many roles plus modules, filters, lookups, inventory plugins and docs, with a namespace and version.

If you only need to share configuration logic, a role is enough. If you ship custom modules or plugins, or want one versioned artifact for your platform team's content, use a collection with the roles inside it. Galaxy standalone roles still work, but new content is expected to be published as collections.

All Ansible questions Roadmap: Ansible

More on Roles, Collections and Galaxy