ansible/ansible
Primitives
The foundational object model: the YAML-shaped Python classes that the executor walks. Everything in lib/ansible/playbook/ is a primitive in this sense — they're the base types that the rest of the engine consumes.
The hierarchy
graph TD
PB[Playbook] -->|contains list of| PLAY[Play]
PLAY -->|may import| INC[PlaybookInclude]
PLAY -->|contains| BLK[Block]
PLAY -->|references| ROLE[Role]
PLAY -->|references| HOST[Host pattern → Host, Group]
BLK -->|contains| TSK[Task]
BLK -->|contains nested| BLK
ROLE -->|contains| BLK
ROLE -->|contains| HND[Handler]
TSK -.->|notifies| HNDPages
| Page | Classes |
|---|---|
| Playbook and play | Playbook, Play, PlaybookInclude |
| Task and block | Task, Block, TaskInclude, Conditional, LoopControl |
| Role and handler | Role, RoleInclude, Handler, HandlerTaskInclude |
| Host and inventory | Host, Group, InventoryData, InventoryManager |
The base class
Every YAML-loadable primitive inherits from lib/ansible/playbook/base.py:Base (or a fixed-attribute variant). Base provides:
- Attributes via
FieldAttribute. Each YAML key (hosts,vars,tasks, etc.) is declared as a class-levelFieldAttribute(name, type, default, ...). The metaclass collects them into a_attributesdict, and the base class'sload_data()walks the dict, validating types and applying templating. - Inheritance. Mixins like
Conditional,Taggable,CollectionSearch,Notifiable,Delegatableadd per-class behaviors. ATask, for instance, inherits all of these plusBase. - Templating integration. Attribute values flow through
_internal/_templating/_engine.pywhen accessed viaget_field_attribute, with templating policy controlled by per-attribute flags.
Cross-links
- Executor — what walks these objects.
- Templating — how attribute values are rendered.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.