Installation Role
Relevant source files
The following files were used as context for generating this wiki page:
The Installation Role prepares the target environment for the opsmill.infrahub collection. It ensures all system-level and Python-level dependencies are present to enable communication with an Infrahub instance. The role manages the setup of the Infrahub SDK, environment variables, and system services required for collection operations.
This role is a core component of the opsmill.infrahub collection infrastructure, providing a standardized entry point for deployment.
Sources: AGENTS.md:3-5, galaxy.yml:32-34
System Requirements and Dependencies
The collection requires specific versions of Python and Ansible to function correctly. The installation process validates these requirements before proceeding with dependency deployment.
Software Specifications
| Component | Required Version |
|---|---|
| Python | >=3.11, <3.15 |
| ansible-core | >=2.19.0 |
| infrahub-sdk | >=1.19.0, <2.0 |
| Jinja2 | >=3.1.6 |
Sources: pyproject.toml:7-14, AGENTS.md:12-21
Python Dependency Management
The project utilizes uv for managing dependencies and ensures the infrahub-sdk is installed with the [all] extras for synchronous support.
Sources: pyproject.toml:13, dev/constitution.md:61, AGENTS.md:20
Role Architecture and Task Flow
The Installation Role is organized into modular task files that separate general installation logic from system-specific configurations like service management.
The diagram shows the logical flow from metadata reading to dependency installation and optional systemd service configuration.
Sources: roles/install/tasks/main.yml, roles/install/tasks/setup_systemd.yml, roles/install/meta/main.yml
Role Metadata
The meta/main.yml file defines the role's identity and galaxy information, which includes the role description and platform compatibility.
Sources: roles/install/meta/main.yml, tasks/docs.py:166-178
System Service Configuration
The setup_systemd.yml task file handles the creation and configuration of systemd unit files. This ensures that any background processes required by Infrahub are managed as persistent system services.
Sources: roles/install/tasks/setup_systemd.yml
Environment Configuration
The installation process configures environment variable fallbacks for the Infrahub API. These variables allow modules to authenticate and connect to the API without hardcoding credentials in playbooks.
| Variable | Description |
|---|---|
INFRAHUB_ADDRESS | Endpoint of the Infrahub API |
INFRAHUB_API_TOKEN | API token for authentication (marked no_log=True) |
Sources: dev/constitution.md:54-55, plugins/AGENTS.md:37-38
SDK Abstraction Layer Setup
The role ensures the infrahub-sdk is correctly configured to work through the InfrahubclientWrapper. This wrapper mediates all API access, ensuring that only the synchronous InfrahubClientSync is used.
The diagram illustrates how the collection abstracts the SDK through a wrapper to communicate with the Infrahub API.
Sources: dev/constitution.md:46-55, plugins/AGENTS.md:65-66
Summary
The Installation Role provides the necessary foundation for using Infrahub within Ansible. It enforces strict versioning for Python and ansible-core, installs the infrahub-sdk, and configures system services via systemd. By setting up environment variable fallbacks and the SDK abstraction layer, the role enables secure and idempotent infrastructure management.
Sources: dev/constitution.md:12-23, AGENTS.md:12-21, roles/install/tasks/setup_systemd.yml