This is the opsmill.infrahub Ansible collection — modules, plugins, and inventory sources for interacting with Infrahub, an infrastructure data platform.
- Namespace:
opsmill - Collection:
infrahub - License: GPLv3
- Repository: https://github.com/opsmill/infrahub-ansible
- Documentation: https://docs.infrahub.app/ansible/
| Component | Version/Tool |
|---|---|
| Python | >=3.10, <3.14 |
| ansible-core | >=2.17.7rc1 (Python 3.10+) |
| infrahub-sdk | >=1.5, <2.0 |
| Linter/Formatter | Ruff (pinned in pyproject.toml) |
| Tests | pytest, ansible-test sanity (Docker-based) |
| Docs | Docusaurus + Jinja2 generation |
| Deps | uv |
| Tasks | Invoke |
# Lint & format
invoke lint # Check (ruff + yamllint)
invoke format # Auto-fix (ruff)
# Tests (all run in Docker)
invoke tests-sanity
invoke tests-unit
invoke tests-integration
invoke tests-all
# Documentation
invoke generate-doc # Regenerate plugin docs from docstrings
invoke docusaurus # Build Docusaurus site
# Build
invoke galaxy-build # Build collection tarballDetailed architecture docs live in dev/knowledge/:
- dev/knowledge/architecture.md — Collection structure, plugin types, data flow
- dev/knowledge/plugin-patterns.md — Ansible boilerplate, docstrings, arg specs, conditional imports
- dev/knowledge/infrahub-sdk-usage.md — SDK wrapper, InfrahubModule, processor classes
| Path | Contents |
|---|---|
plugins/modules/ |
Module stubs (DOCUMENTATION + AnsibleModule) |
plugins/action/ |
Action plugins (controller-side logic) |
plugins/module_utils/infrahub_utils.py |
Core: InfrahubclientWrapper, InfrahubModule, processors (~1500 lines) |
plugins/module_utils/node.py |
NodeModule (node CRUD) |
plugins/module_utils/branch.py |
BranchModule (branch CRUD) |
plugins/module_utils/exception.py |
SDK exception → Ansible error mapping |
plugins/inventory/inventory.py |
Dynamic inventory plugin |
plugins/lookup/lookup.py |
GraphQL lookup plugin |
plugins/doc_fragments/fragments.py |
Reusable DOCUMENTATION fragments |
- dev/guidelines/python.md — Ruff config, line length 120, quote style, import sorting
- dev/guidelines/testing.md — Docker test execution, mocking patterns, pytest config
- dev/guidelines/documentation.md — Doc generation pipeline, docstring format
- dev/guidelines/git-workflow.md — Branch model (develop/stable), PR conventions
These files are generated by invoke generate-doc:
docs/docs/references/plugins/*.mdx
docs/docs/readme.mdx
Edit the source docstrings in plugins/modules/*.py or the Jinja2 templates in docs/_templates/ instead.
Run these commands as part of your workflow — not just at the end, but as you go:
invoke lint # Verify lint passes
invoke tests-sanity # Verify Ansible compliance (boilerplate, docs, imports)invoke generate-doc # Regenerate plugin reference MDX from docstringsinvoke tests-unit # Run unit testsinvoke format # Auto-fix formatting (ruff)
invoke lint # Check lint (ruff + yamllint)invoke format # Fix formatting
invoke lint # Check lint
invoke tests-sanity # Ansible compliance
invoke tests-unit # Unit tests
invoke generate-doc # Regenerate docs- Use the conditional import pattern for
infrahub-sdk(HAS_INFRAHUBCLIENT) - Include
__metaclass__ = typeandfrom __future__ importboilerplate in plugin files - Use
no_log=Truefor token/secret parameters - Run
invoke tests-sanityafter modifying plugins - Run
invoke generate-docafter changing module docstrings - Run
invoke formattheninvoke lintafter any Python change - Follow the existing module patterns (see
dev/knowledge/plugin-patterns.md) - Use
deepcopy(INFRAHUB_ARG_SPEC)when extending the standard argument spec
- Adding new dependencies to
pyproject.toml - Changing the ruff configuration or ignoring new rules
- Modifying
plugins/module_utils/infrahub_utils.py(core shared code, ~1500 lines) - Changing the
INFRAHUB_ARG_SPEC(affects all modules using it) - Modifying CI workflows in
.github/workflows/
- Edit generated files in
docs/docs/references/plugins/ - Remove the
__metaclass__ = typeor__future__imports (breaksansible-test sanity) - Use async SDK methods (this collection is synchronous only)
- Hardcode credentials — always use environment variable fallbacks
- Skip the conditional
HAS_INFRAHUBCLIENTcheck in any plugin