Ansible
This section documents our opinionated approach to writing, organizing, and operating Ansible code. It covers naming conventions, structural guidelines, state management, and everyday best practices that every engineer working on infrastructure automation should follow.
Sections
| Section | Description |
|---|---|
| Project Structure | Repository layout and directory organization |
| Naming Conventions | Standardized role, task, and variable naming patterns |
| Module Design | Guidelines for writing and consuming Ansible modules |
| State Management | Idempotency principles and state tracking strategies |
| Variables & Outputs | Variable precedence, typing, and output conventions |
| Provider Configuration | SSH, WinRM, and cloud provider authentication setup |
| Anti-Patterns | Common mistakes and how to avoid them |
| CI/CD Pipeline | Workflow rules, linting, testing, and pipeline setup |
| Security & Compliance | Secrets handling, privilege escalation, and hardening |
Guiding Principles
- Consistency Over Preference: Follow the patterns in this playbook even when you disagree. Raise a discussion to change the standard instead of diverging silently.
- Idempotency Always: Every task must be safe to run multiple times without changing the outcome after the first successful run.
- Least Privilege By Default: Use
becomeonly where strictly necessary. Prefer targeted privilege escalation over broadsudoaccess. - Code Review Everything: No playbook runs directly against production from a developer machine. All changes go through CI/CD.