0Pricing
Ansible Academy · Lesson

Naming, Comments & Style That Scale

Conventions that keep projects readable.

Naming, Comments & Style That Scale is a free Ansible Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Style Is Not Optional

Playbooks are read far more than they are written. Consistent naming and style turn a personal script into team-ready automation. ✨

Always Name Your Tasks

Give every task a clear name. Named tasks make run output readable and tell teammates the intent at a glance.

- name: Install the nginx web server
  package:
    name: nginx
    state: present

Write Names as Actions

Phrase names as clear actions like Install nginx or Create deploy user. They read like a checklist when the play runs.

Prefer Native Modules

Reach for a real module over the shell or command module. Modules are idempotent and self-documenting; raw commands are not.

Use YAML, Not key=value

Write module arguments in clear YAML block style, one key per line, rather than cramming everything onto one inline string.

- name: Ensure dir exists
  file:
    path: /opt/app
    state: directory

Comments Explain Why

Use a # comment to explain why, not what. The task name already says what; comments capture the reason or a gotcha.

# Pin version: 1.20 broke our TLS config
- name: Install nginx 1.18
  package:
    name: nginx=1.18*

Consistent Variable Names

Name variables in lower snake_case and prefix role vars with the role name to avoid clashes, like nginx_port.

Quote When in Doubt

Quote any value that starts with {{ or could be read as a number or boolean, so YAML never guesses the type wrong.

msg: "{{ greeting }}"
version: "1.10"

Two-Space Indentation

Stick to two spaces per level and never tabs. YAML is whitespace-sensitive, so mixed indentation breaks parsing.

Let ansible-lint Enforce It

Run ansible-lint to catch style and best-practice issues automatically. Let the tool police conventions so reviews focus on logic.

ansible-lint site.yml

Small, Focused Files

Keep each file doing one job. A short, well-named task file is easier to test, reuse and reason about than a sprawling one. 🎯

Quick Check

What is the main reason to add name to every task?

Recap

You learned to name every task, favor modules over shell, write clear YAML, comment the why, and let ansible-lint enforce style. ✅

Frequently asked questions

Is the “Naming, Comments & Style That Scale” lesson free?

Yes — the full text of “Naming, Comments & Style That Scale” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.

What will I learn in “Naming, Comments & Style That Scale”?

Conventions that keep projects readable. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ansible Academy?

No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Naming, Comments & Style That Scale” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ansible Academy lesson?

Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The Recommended Directory Layout
  2. group_vars & host_vars Directories
  3. Splitting Playbooks with import & include
  4. Naming, Comments & Style That Scale
← Back to Ansible Academy