Memory hook: A role organizes intent; a collection distributes content.
Must remember
A role organizes tasks, handlers, defaults, variables, templates, files and metadata into a reusable structure. Defaults expose override-friendly settings; role variables have different precedence and should not casually lock consumers out of configuration. Keep a role focused on a clear responsibility and document its inputs and dependencies.
A collection packages related modules, plugins, roles and other content under a namespace/name. Install the required collection version into a path visible to the execution environment. A module available in the controller's Python environment may not exist inside navigator's selected container.
Use ansible-galaxy and a requirements file for supported role/collection installation. Pin or constrain versions according to the environment, then inspect their documentation. Offline exam environments may supply content or repositories; practice finding and using those rather than relying on an internet download.
ansible-doc and navigator documentation views show module arguments, defaults, examples and return values. Confirm whether a module is in ansible.builtin, ansible.posix, community.general or a vendor/system-role collection. A short module name can hide a dependency or select an unintended implementation.
Static imports and dynamic includes differ in when content is processed, affecting conditions, loops, tags and task visibility. Understand the chosen pattern instead of interchanging them blindly. Test a role in isolation and as part of the full play, including repeated execution and multiple hosts with different variable values.
Choose under exam pressure
| Requirement | Choice and reason |
|---|---|
| Share a reusable configuration responsibility | A role with documented defaults and inputs. |
| Distribute modules plus related roles | A collection. |
| Unsure about a module parameter | Installed documentation for the actual runtime version. |
Traps
- Installing a collection on the host does not necessarily install it in an execution environment.
- Role defaults and role vars do not have the same override behavior.
Active recall
1. Role versus collection?
Organized reusable automation logic versus a distribution package that can contain roles, modules and plugins.
2. Why maintain requirements?
To make content dependencies and versions reproducible.
3. What does ansible-doc reveal?
Supported arguments, examples, return data and behavior for installed modules/plugins.
4. Why use offline documentation practice?
The practical exam may provide local docs without internet access.
5. Why distinguish import and include?
Static and dynamic processing change when and how tasks are expanded.