Object Creator
Overview
Expert guidance for creating Infrahub object (data) files.
Objects are YAML files that populate schema nodes with actual
infrastructure data -- devices, locations, organizations,
modules, and more.
Project Context
Existing schema files:
!find . -name "*.yml" -path "*/schemas/*" -o -name "*schema*" -name "*.yml" 2>/dev/null | head -10
Existing object files:
!find . -name "*.yml" -path "*/objects/*" 2>/dev/null | head -20
If invoked with arguments (e.g., /infrahub:managing-objects DcimDevice spine-01),
use the first argument as the kind and remaining arguments as object details.
When to Use
- Creating new data files for infrastructure objects
- Populating devices, locations, organizations, or other schema nodes
- Setting up hierarchical data (location trees, tenant groups)
- Referencing related objects across files
- Managing component children (interfaces, modules)
- Organizing object files for correct load order
Rule Categories
| Priority |
Category |
Prefix |
Description |
| CRITICAL |
Branch-First Loading |
workflow- |
Load onto a branch, not the default branch |
| CRITICAL |
File Format |
format- |
apiVersion, kind, spec structure |
| CRITICAL |
Value Mapping |
value- |
Attributes, dropdowns, references |
| HIGH |
Children |
children- |
Hierarchy/component nesting |
| MEDIUM |
Range |
range- |
Sequential interface expansion |
| MEDIUM |
Organization |
organization- |
Naming, load order, multi-doc |
| LOW |
Patterns |
patterns- |
Flat lists, devices, git repos |
Schema Features This Skill Depends On
Object files reference schema-defined shapes; missing
schema setup turns into "object failed to load" or
"reference not found" errors at sync time. Before
populating data, verify the schema upstream:
If any of these is missing, the schema needs an
update before the objects can load — that's a
schema migration, not an object fix.
Object File Basics
---
apiVersion: infrahub.app/v1
kind: Object
spec:
kind: <NodeKind> # Schema node kind (e.g., DcimDellServer)
data:
- <attribute>: <value> # List of object instances
apiVersion, kind: Object, spec.kind, and spec.data
are always required. Each spec block targets a single
node kind.
Workflow
Follow these steps when creating object data files:
- Plan to load onto a branch, not the default branch —
Decide the dedicated branch this data will load onto
before writing the files, and surface it when you hand
off the load commands. Loading into the default branch
(the target when no
--branch is given — main by
convention, but it can be renamed) writes unreviewed
data to the source of truth, and a bad bulk load there
means deleting objects one by one instead of discarding
a branch. Read
rules/workflow-branch-first.md.
The default branch is only reasonable on a local
throwaway instance.
- Read the schema — Identify the target node kind,
its attributes, relationships, and whether it has
component children or hierarchy parents.
- Plan the file structure — Read
rules/format-structure.md
for the required YAML structure and
rules/organization-load-order.md
for file naming and load order conventions.
- Map attribute values — Set each attribute using
the correct value format. Read
rules/value-attributes.md
for attribute mapping and
rules/value-relationships.md
for relationship references. If the object should inherit
shared defaults from a Profile or be created from an Object
Template, read
rules/value-profiles-templates.md.
To stamp lineage or lock
a value, write it as a
value + metadata mapping —
see ../infrahub-common/metadata-lineage.md
(remember source is lineage only; locking needs
owner + is_protected).
- Handle children — If the node has component
children or hierarchy nesting, read
rules/children-components.md
and rules/children-hierarchy.md.
- Validate and load on the branch — Check YAML syntax,
ensure referenced objects exist or are defined in
earlier load-order files, then validate and load against
your branch (
--branch). See
validation.md for the commands and
pre-load checklist.
Supporting References
1---2name: infrahub-managing-objects-33description: >-4 Creates and manages Infrahub object data YAML files for populating infrastructure instances — devices, locations, organizations, and modules.5 TRIGGER when: creating device instances, populating data files, defining locations or organizations, adding infrastructure objects.6 DO NOT TRIGGER when: designing schemas, writing Python checks/generators, querying live data.7allowed-tools:8 - Read9 - Write10 - Edit11 - Bash12argument-hint: "[kind] [object-details...]"13metadata:14 source: https://skillmd.com/skills/opsmill/infrahub-managing-objects-315 version: 1.2.816 author: OpsMill17---1819# Object Creator2021## Overview2223Expert guidance for creating Infrahub object (data) files.24Objects are YAML files that populate schema nodes with actual25infrastructure data -- devices, locations, organizations,26modules, and more.2728## Project Context2930Existing schema files:31!`find . -name "*.yml" -path "*/schemas/*" -o -name "*schema*" -name "*.yml" 2>/dev/null | head -10`3233Existing object files:34!`find . -name "*.yml" -path "*/objects/*" 2>/dev/null | head -20`3536If invoked with arguments (e.g., `/infrahub:managing-objects DcimDevice spine-01`),37use the first argument as the kind and remaining arguments as object details.3839## When to Use4041- Creating new data files for infrastructure objects42- Populating devices, locations, organizations, or other schema nodes43- Setting up hierarchical data (location trees, tenant groups)44- Referencing related objects across files45- Managing component children (interfaces, modules)46- Organizing object files for correct load order4748## Rule Categories4950| Priority | Category | Prefix | Description |51| -------- | -------- | ------ | ----------- |52| CRITICAL | Branch-First Loading | `workflow-` | Load onto a branch, not the default branch |53| CRITICAL | File Format | `format-` | apiVersion, kind, spec structure |54| CRITICAL | Value Mapping | `value-` | Attributes, dropdowns, references |55| HIGH | Children | `children-` | Hierarchy/component nesting |56| MEDIUM | Range | `range-` | Sequential interface expansion |57| MEDIUM | Organization | `organization-` | Naming, load order, multi-doc |58| LOW | Patterns | `patterns-` | Flat lists, devices, git repos |5960## Schema Features This Skill Depends On6162Object files reference schema-defined shapes; missing63schema setup turns into "object failed to load" or64"reference not found" errors at sync time. Before65populating data, verify the schema upstream:6667| If the object... | The schema must... | See |68| ---------------- | ------------------ | --- |69| References another object across files | Define `human_friendly_id` on the target node (the shape determines scalar-vs-list reference) | [../infrahub-managing-schemas/rules/display-human-friendly-id.md](../infrahub-managing-schemas/rules/display-human-friendly-id.md) |70| Sits in a location/parent tree | Use a hierarchical generic with `parent`/`children` and full-kind peer references | [../infrahub-managing-schemas/rules/hierarchy-setup.md](../infrahub-managing-schemas/rules/hierarchy-setup.md) |71| Sets a Dropdown attribute value | Declare the dropdown `choices` as objects with `name` (not bare strings); the object references the choice `name` | [../infrahub-managing-schemas/rules/attribute-defaults-and-types.md](../infrahub-managing-schemas/rules/attribute-defaults-and-types.md) |72| Owns Component children inline | The parent's Component relationship and child's Parent relationship must share an identifier and the child needs `optional: false` | [../infrahub-managing-schemas/rules/relationship-component-parent.md](../infrahub-managing-schemas/rules/relationship-component-parent.md) |73| Will be the target of an artifact pipeline | The concrete node must `inherit_from: CoreArtifactTarget` (set on the node, not on a generic) | [../infrahub-managing-schemas/rules/extension-artifact-target.md](../infrahub-managing-schemas/rules/extension-artifact-target.md) |7475If any of these is missing, the schema needs an76update before the objects can load — that's a77schema migration, not an object fix.7879## Object File Basics8081```yaml82---83apiVersion: infrahub.app/v184kind: Object85spec:86 kind: <NodeKind> # Schema node kind (e.g., DcimDellServer)87 data:88 - <attribute>: <value> # List of object instances89```9091`apiVersion`, `kind: Object`, `spec.kind`, and `spec.data`92are always required. Each `spec` block targets a single93node kind.9495## Workflow9697Follow these steps when creating object data files:98991. **Plan to load onto a branch, not the default branch** —100 Decide the dedicated branch this data will load onto101 before writing the files, and surface it when you hand102 off the load commands. Loading into the default branch103 (the target when no `--branch` is given — `main` by104 convention, but it can be renamed) writes unreviewed105 data to the source of truth, and a bad bulk load there106 means deleting objects one by one instead of discarding107 a branch. Read108 [rules/workflow-branch-first.md](./rules/workflow-branch-first.md).109 The default branch is only reasonable on a local110 throwaway instance.1112. **Read the schema** — Identify the target node kind,112 its attributes, relationships, and whether it has113 component children or hierarchy parents.1143. **Plan the file structure** — Read115 [rules/format-structure.md](./rules/format-structure.md)116 for the required YAML structure and117 [rules/organization-load-order.md](./rules/organization-load-order.md)118 for file naming and load order conventions.1194. **Map attribute values** — Set each attribute using120 the correct value format. Read121 [rules/value-attributes.md](./rules/value-attributes.md)122 for attribute mapping and123 [rules/value-relationships.md](./rules/value-relationships.md)124 for relationship references. If the object should inherit125 shared defaults from a Profile or be created from an Object126 Template, read127 [rules/value-profiles-templates.md](./rules/value-profiles-templates.md).128 To stamp lineage or lock129 a value, write it as a `value` + metadata mapping —130 see [../infrahub-common/metadata-lineage.md](../infrahub-common/metadata-lineage.md)131 (remember `source` is lineage only; locking needs132 `owner` + `is_protected`).1335. **Handle children** — If the node has component134 children or hierarchy nesting, read135 [rules/children-components.md](./rules/children-components.md)136 and [rules/children-hierarchy.md](./rules/children-hierarchy.md).1376. **Validate and load on the branch** — Check YAML syntax,138 ensure referenced objects exist or are defined in139 earlier load-order files, then validate and load against140 your branch (`--branch`). See141 [validation.md](./validation.md) for the commands and142 pre-load checklist.143144## Supporting References145146- **[reference.md](./reference.md)** -- Object file format147 specification148- **[validation.md](./validation.md)** --149 `infrahubctl object validate` / `object load`150 commands, common load errors, pre-load checklist151- **[examples.md](./examples.md)** -- 15 complete object152 patterns from production repos153- **[../infrahub-common/infrahub-yml-reference.md](../infrahub-common/infrahub-yml-reference.md)**154 -- .infrahub.yml project configuration155- **[../infrahub-common/marketplace-reference.md](../infrahub-common/marketplace-reference.md)**156 -- if the schema these objects populate came from the157 marketplace, reuse it rather than modelling a new one158- **[../infrahub-common/metadata-lineage.md](../infrahub-common/metadata-lineage.md)**159 -- Value metadata (`source`, `owner`, `is_protected`):160 setting lineage/ownership and why `source` does not161 control edit access162- **[../infrahub-common/rules/](../infrahub-common/rules/)** -- Shared rules163 (git integration, caching) across all skills164- **[../infrahub-common/rules/workflow-information-priority.md](../infrahub-common/rules/workflow-information-priority.md)**165 -- Skill content first; how to consult `docs.infrahub.app`166 on a genuine gap (e.g. deleting nodes)167- **[../infrahub-managing-schemas/SKILL.md](../infrahub-managing-schemas/SKILL.md)**168 -- Schema definitions these objects conform to169- **[rules/](./rules/)** -- Individual rules by category170 prefix