Ansible: Automation for Your Lab

Ansible is my go-to tool for automating home lab setup and management. For a clean install, I recommend using uv to manage Python and Ansible dependencies—it keeps your environment tidy and repeatable.

To test your Ansible playbooks, use Multipass to spin up local VM. Set up SSH access for the root user using SSH keys only, and always disable password login for security.

If you want a lightweight web UI to manage and schedule your playbooks, try Semaphore. It’s easy to set up, supports cron-like scheduling, and uses a portable Bolt database.

Managing Python Environments with uv

uv is a modern Python package and environment manager that stands out for several reasons.

  • Speed: uv is significantly faster than traditional tools like pip and virtualenv.
  • Portability: uv is a single binary with no dependencies, making it easy to use across different systems.
  • Container/Docker friendly: It's portability and single-binary design make it ideal for packaging Python environment inside containers, simplifying Docker builds and reducing image size.

Installing uv

curl -LsSf https://astral.sh/uv/install.sh | sh

Initializing Ansible Project with uv

uv init
uv add ansible
uv sync

Centralized Execution with Semaphore UI

In production homelab environments, executing playbooks directly from developer workstations or ad-hoc agent shells introduces drift and risk. Instead, standardise on a central execution plane using Semaphore UI:

  • Single Execution Path: All playbook runs, checks, and applies run consistently from Semaphore against predefined inventories.
  • Strict Verification: Review playbook diffs (--check / dry run) in the UI before executing writes or state changes against bare-metal hosts.
  • Centralized Secrets: Inject credentials (SSH keys, vault passwords, environment variables) directly inside Semaphore environments rather than distributing them across local machines.