Open-Source Wikis

/

Ansible

/

Primitives

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| HND

Pages

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-level FieldAttribute(name, type, default, ...). The metaclass collects them into a _attributes dict, and the base class's load_data() walks the dict, validating types and applying templating.
  • Inheritance. Mixins like Conditional, Taggable, CollectionSearch, Notifiable, Delegatable add per-class behaviors. A Task, for instance, inherits all of these plus Base.
  • Templating integration. Attribute values flow through _internal/_templating/_engine.py when accessed via get_field_attribute, with templating policy controlled by per-attribute flags.
  • 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.

Primitives – Ansible wiki | Factory