Understanding Artifact Lifecycle Management
This topic explores how Infrahub's artifact system works with Nornir to enable sophisticated configuration management workflows. Understanding artifact lifecycle management is crucial for implementing robust, auditable network automation.
Introduction​
Artifacts in Infrahub are generated outputs based on your infrastructure data and templates. They represent the "rendered truth" of your infrastructure at any point in time. This document explains:
- What artifacts are and why they matter
- How artifacts flow through generation, storage, and deployment
- The relationship between artifacts, templates, and infrastructure data
- How version control applies to generated configurations
What are artifacts?​
Definition​
An artifact is any generated content that represents infrastructure state:
- Device configurations
- Compliance reports
- Documentation
- API payloads
- Validation results
Key characteristics​
Artifacts are:
- Generated: Created from templates + data, not manually written
- Versioned: Each generation creates a new version
- Immutable: Once generated, artifacts don't change
- Traceable: Linked to the exact data and templates used
References​
For detailed information about artifacts in Infrahub:
- Artifact Topic - How artifacts work in Infrahub
- Transformation Topic - How transformations generate artifacts
- Repository Configuration Reference -
.infrahub.ymlartifact definition syntax
Artifact management with Nornir​
Task plugin functions​
The Nornir-Infrahub plugin provides three key functions:
generate_artifacts()​
Triggers generation for all targets in a definition:
# Generate configs for all edge devices
nr.run(task=generate_artifacts, artifact="Startup Config for Edge devices")
This is typically used:
- After template updates
- On scheduled intervals
- Before deployment windows
regenerate_host_artifact()​
Regenerates artifact for specific hosts:
# Regenerate after device-specific change
changed_devices = nr.filter(name="atl1-edge1")
changed_devices.run(task=regenerate_host_artifact, artifact="Startup Config for Edge devices")
Use cases:
- After individual device updates
- Testing template changes
- Troubleshooting specific devices
get_artifact()​
Retrieves stored artifact content:
# Get current config for deployment
result = nr.run(task=get_artifact, artifact="Startup Config for Edge devices")
for host, task_result in result.items():
config = task_result.result
# Deploy config to device
Use cases:
- Deploying configurations to devices
- Comparing current vs desired state
- Feeding into validation pipelines
Version control integration​
Branch-aware artifacts​
Artifacts are generated per branch:
main branch:
atl1-edge1 startup-config v3 (current)
atl1-edge1 startup-config v2
atl1-edge1 startup-config v1
feature branch:
atl1-edge1 startup-config v2 (testing changes)
atl1-edge1 startup-config v1
This enables:
- Safe testing in feature branches
- Comparison between branches
- Controlled promotion to production
Practical workflows​
Configuration deployment​
- Generate: Create new configs from current data
- Validate: Check configs before deployment
- Deploy: Push to devices
- Verify: Confirm successful application
Compliance auditing​
- Define: Create compliance report template
- Generate: Run against all devices
- Review: Identify non-compliant devices
- Remediate: Fix issues and regenerate
Disaster recovery​
- Regular Generation: Keep artifacts current
- Backup Storage: Replicate artifact store
- Rapid Recovery: Deploy last-known-good configs
Advanced concepts​
Conditional generation​
Generate only when needed:
# Check if regeneration needed
if device.last_modified > artifact.generated_at:
nr.run(task=regenerate_host_artifact, artifact="Startup Config for Edge devices")
Further reading​
- Your First Automation Workflow - Implement artifact workflows with Nornir
- Artifact Management Plugin Reference - Full API documentation for artifact tasks