From 3f3781437b74fb5744069a3d193b603bb242a251 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Thu, 12 Nov 2026 23:06:14 +0100 Subject: [PATCH] Prefer grouping similar Ansible tasks into looping list variables Record in both the shared Ansible rules (~/.config/ai/rules/ansible.md) and the repo Conventions that similar tasks should be declared as list variables, typically in group_vars, and applied by a single task looping over the list instead of near-identical one-per-item tasks. Co-Authored-By: Cline --- AGENTS.md | 2 ++ dotfiles/common/.config/ai/rules/ansible.md | 1 + 2 files changed, 3 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 48e2564..c7b7a0c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -105,6 +105,8 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora - Prefer declarative modules over `command`/`shell`; when `shell` is required, make idempotency and failure behavior explicit. - Start YAML files with `---`, use 2-space indentation, and keep file modes quoted like `"0644"`. - Keep booleans as booleans and structured vars as YAML lists/maps. +- Group similar tasks into list variables (typically in `group_vars`) and apply them + with a single task looping over the list, rather than one near-identical task per item. - Put host-specific overrides in `host_vars`, not shared `group_vars`. - Use `no_log: true` for secret-bearing task inputs or outputs. diff --git a/dotfiles/common/.config/ai/rules/ansible.md b/dotfiles/common/.config/ai/rules/ansible.md index 1c37f99..20aa87c 100644 --- a/dotfiles/common/.config/ai/rules/ansible.md +++ b/dotfiles/common/.config/ai/rules/ansible.md @@ -4,3 +4,4 @@ - Keep tasks idempotent - Use group_vars and host_vars properly - Avoid duplication +- Group similar tasks into list variables and apply them with a single looping task