Skip to main content

Modules modules

Load, check, or export schemas in Infrahub through the Infrahub SDK. Use C(action=load) to load schemas into Infrahub. Use C(action=check) to validate schemas without applying them. Use C(action=export) to export existing schemas from Infrahub.

Parameters

ParameterTypeRequiredDefaultDescription
api_endpointstrNoEndpoint of the Infrahub API, optional env=INFRAHUB_ADDRESS
tokenstrNoThe API token created through Infrahub, optional env=INFRAHUB_API_TOKEN
timeoutintNo10Timeout for Infrahub requests in seconds
validate_certsboolNoTrueWhether or not to validate SSL of the Infrahub instance
actionstrYesThe schema action to perform. C(load) loads schemas into Infrahub. C(check) validates schemas without applying them. C(export) exports existing schemas from Infrahub.
branchstrNomainBranch in which the request is made
schemaslistNoList of inline schema definitions (nodes and generics). For C(load) and C(check), at least one of C(schemas) or C(schema_files) must be provided.
schema_fileslistNoList of YAML file paths containing schema definitions. Files are read on the Ansible controller. For C(load) and C(check), at least one of C(schemas) or C(schema_files) must be provided.
namespaceslistNoList of namespace names to filter the export. Only used with C(action=export).
wait_until_convergedboolNoFalseWait for schema to be synchronized across all workers. Only used with C(action=load).

Examples

---
- name: Check schema from inline definition
opsmill.infrahub.schema:
action: check
schemas:
- name: Site
namespace: Location
attributes:
- name: name
kind: Text
unique: true

- name: Load schema from file
opsmill.infrahub.schema:
action: load
schema_files:
- "schemas/my_schema.yml"

- name: Load schema with convergence wait
opsmill.infrahub.schema:
action: load
schema_files:
- "schemas/my_schema.yml"
wait_until_converged: true

- name: Export all schemas
opsmill.infrahub.schema:
action: export
register: result

- name: Export schemas for specific namespaces
opsmill.infrahub.schema:
action: export
namespaces:
- Infra
- Location
register: result

Return values

KeyTypeDescription
changedboolWhether the schema was updated (load) or always false (check/export).
schema_updatedboolWhether the schema hash changed after loading.
hashstrNew schema hash after loading.
previous_hashstrPrevious schema hash before loading.
warningslistSchema warnings returned during load.
validboolWhether the schema passed validation.
errorsdictValidation errors when schema check fails.
schemasdictExported schemas organized by namespace.
msgstrMessage indicating the result of the operation.