Prefix public role variables with the role name, internal role variables with __role_name_, inventory-only variables with a project prefix, and separate words with underscores in Ansible variable names.
Use item as the default loop variable. Reserve loop_control.loop_var for cases where item would collide across loop boundaries, such as nested loops and include_tasks.
Prefer dot notation for fixed keys. Use bracket notation only when dot notation cannot express the access safely or correctly.
Define download URLs and paths in variables instead of hardcoding them in tasks.
Use loop_control.label to keep Ansible loop output short and readable when a loop iterates over dictionaries or other large values.
When targeting MS Windows hosts, use slashes for all paths. Convert to backslashes only if necessary.
Use a consistent tagging structure in
Ansible roles to make playbook runs more targeted and maintainable.
Use dictionary merging deliberately and predictably in Ansible inventories to keep overrides maintainable.
Prefer short, consistent names that reduce noise without making variables or identifiers unclear.
Prefer import_tasks, import_role, or the play-level roles section for reusable Ansible content. Use include_tasks or include_role only when you need dynamic runtime behavior.