Ansible
Keeps Ansible itself managed: installs ansible-core with a matched mitogen (uv-managed by default, apt opt-in), applies this host's configured roles, and configures shell aliases.
Demo

What it does
- Installs ansible-core, mitogen, and ansible-lint in one uv-managed environment (the default), or via apt with
ansible_install_method: apt(Ubuntu 24.04+) - Migrating apt to uv is a clean switch: the role removes a shadowing user-site pip Ansible (never apt's system packages) and registers the mitogen strategy plugins in
~/.ansible/plugins/strategy - Applies the roles listed in
ansible_roles_all/ansible_roles_extra(an alternative to a staticroles:block) - Shell aliases for running the playbook
Variables
| Variable | Default | Description |
|---|---|---|
ansible_install_method | uv | How Ansible is installed: uv (a current ansible-core with a matched mitogen in one isolated env) or apt (Ubuntu 24.04+ system packages; apt's ansible-mitogen hard-aborts under any newer ansible-core installed alongside it). |
ansible_uv_python | "3.14" | Python the uv-managed Ansible runs on. Drop to 3.13 / 3.12 if mitogen misbehaves on the newest interpreter. |
A data-driven alternative to a static roles: block, so different machines run different roles from one playbook. Three stages, each overridable:
| Variable | Default | Description |
|---|---|---|
ansible_roles_all | [] | The baseline list of roles for all hosts (set in group_vars/all.yaml). |
ansible_roles_extra | roles_extra (or []) | Extra roles for this host (set in host_vars), merged onto the baseline. Reads the bare roles_extra var so playbook config can set it without the prefix. |
ansible_roles_include | ansible_roles_all + ansible_roles_extra, de-duplicated, minus the ansible role | The finalized list the role includes, computed. Entries may be short names (resolved in this collection) or fully-qualified namespace.collection.role, so a fleet can mix in a company collection. |
Examples
ansible_roles_all sets the baseline for every host; ansible_roles_extra adds to it per host. The two merge into ansible_roles_include:
yaml
# group_vars/all.yaml: every host gets these
ansible_roles_all: # default: []
- ubuntu
- bash
- git
- starshipyaml
# host_vars/work-laptop.yaml: extra roles for one machine
ansible_roles_extra: # default: the bare `roles_extra` var, else []
- docker
- kubernetes
- acme.internal.devtools # fully-qualified role from a company collectionAliases
| Alias | Command | Description |
|---|---|---|
play | ansible-playbook --diff --ask-become-pass $ANSIBLE_PLAYBOOK | Run the playbook with diff output |
playcheck | ansible-playbook --check --diff --ask-become-pass $ANSIBLE_PLAYBOOK | Dry-run the playbook with diff output |
The playbook comes from $ANSIBLE_PLAYBOOK when exported; with the variable unset, pass it as an argument: play playbook.yaml.