Introduction

The name[casing] rule in Ansible Lint requires that all task and play names start with an uppercase letter. This ensures consistent, professional output in logs, Ansible Tower/AWX job output, and terminal displays. This article covers the rule, why it matters, how to fix violations, and how to auto-fix existing playbooks.

The Rule

Every name: field in plays, tasks, handlers, and blocks must start with an uppercase letter (A-Z).

Problematic Code

---
- name: example playbook
  hosts: all
  tasks:
    - name: install nginx
      ansible.builtin.apt:
        name: nginx
        state: present

    - name: start nginx service
      ansible.builtin.service:
        name: nginx
        state: started

Lint Output

$ ansible-lint playbook.yml
WARNING  Listing 3 violation(s) that are fatal
name[casing]: All names should start with an uppercase letter.
playbook.yml:2 Play: example playbook

name[casing]: All names should start with an uppercase letter.
playbook.yml:5 Task/Handler: install nginx

name[casing]: All names should start with an uppercase letter.
playbook.yml:10 Task/Handler: start nginx service

                   Rule Violation Summary
 count tag          profile  rule associated tags
     3 name[casing] moderate idiom

Failed: 3 failure(s), 0 warning(s) on 1 files.

Fixed Code

---
- name: Example playbook
  hosts: all
  tasks:
    - name: Install nginx
      ansible.builtin.apt:
        name: nginx
        state: present

    - name: Start nginx service
      ansible.builtin.service:
        name: nginx
        state: started

Why Uppercase Matters

1. Professional Log Output

Task names appear in playbook output, Tower/AWX job logs, and ARA records:

TASK [install nginx] *****     ← looks sloppy
TASK [Install nginx] *****     ← looks professional

2. Consistency Across Teams

Without a standard, you end up with mixed styles:

# ❌ Inconsistent — hard to scan
- name: install packages
- name: Configure Nginx
- name: DEPLOY application
- name: restart Services
# ✅ Consistent — easy to scan
- name: Install packages
- name: Configure Nginx
- name: Deploy application
- name: Restart services

3. Sentence Case Is Natural English

Task names read as sentences describing what the task does. English sentences start with uppercase:

- name: Ensure nginx is installed and running
- name: Create application directories
- name: Deploy configuration from template

Where the Rule Applies

LocationApplies?Example
Play name✅ Yes- name: Deploy webserver
Task name✅ Yes- name: Install packages
Handler name✅ Yes- name: Restart nginx
Block name✅ Yes- name: Database setup
Role name❌ NoRole names use snake_case
Variable names❌ NoVariables use snake_case

Auto-Fix

ansible-lint can automatically capitalize task names:

# Preview changes
ansible-lint --fix --diff playbook.yml

# Apply fixes
ansible-lint --fix playbook.yml

Before Auto-Fix

- name: install nginx
  ansible.builtin.apt:
    name: nginx

After Auto-Fix

- name: Install nginx
  ansible.builtin.apt:
    name: nginx

Bulk Fix All Files

# Fix all YAML files in a project
ansible-lint --fix roles/ playbooks/

Edge Cases

Names Starting with Modules or Commands

# ❌ Starts with lowercase module name
- name: ansible.builtin.apt install
  ansible.builtin.apt:
    name: nginx

# ✅ Start with a verb
- name: Install nginx with apt
  ansible.builtin.apt:
    name: nginx

Names with Variables (Jinja2)

# ❌ Starts with a variable (lowercase after rendering)
- name: "{{ package_name }} installation"
  ansible.builtin.apt:
    name: "{{ package_name }}"

# ✅ Start with uppercase text before variable
- name: "Install {{ package_name }}"
  ansible.builtin.apt:
    name: "{{ package_name }}"

Acronyms

# ✅ Acronyms are fine — they start with uppercase
- name: SSH key deployment
- name: DNS configuration
- name: SSL certificate renewal
- name: HTTP health check

With name[prefix] Rule

If you also use the name[prefix] rule, capitalize after the prefix:

# ❌ Wrong
- name: install | install nginx

# ✅ Right
- name: install | Install nginx

Task Naming Best Practices

Use Action Verbs

# ✅ Good — clear action verbs
- name: Install required packages
- name: Create application user
- name: Deploy configuration template
- name: Start and enable service
- name: Configure firewall rules
- name: Verify service health
# ❌ Vague — what does the task do?
- name: Packages
- name: User stuff
- name: Config
- name: Service

Be Specific

# ❌ Too generic
- name: Install package
- name: Copy file
- name: Run command

# ✅ Specific
- name: Install nginx web server
- name: Copy SSL certificate to /etc/ssl/certs
- name: Run database migration script

Describe the Desired State

# ✅ Describes the end state
- name: Ensure nginx is installed
- name: Ensure /var/www exists with correct permissions
- name: Ensure firewall allows port 443

# This style works well with idempotent tasks

Disabling the Rule

If you have a legitimate reason to skip the rule:

Per-Task Skip

- name: iPhone configuration  # noqa: name[casing]
  ansible.builtin.debug:
    msg: "Product names may start lowercase"

In .ansible-lint Config

# .ansible-lint
skip_list:
  - name[casing]  # not recommended — keep it enabled
RuleDescriptionProfile
name[casing]Names start with uppercasemoderate
name[play]All plays must have a namebasic
name[missing]All tasks must have a namebasic
name[prefix]Prefix with file stem (opt-in)opt-in
name[template]No Jinja2 in names (opt-in)opt-in

Conclusion

The name[casing] rule ensures all task and play names start with an uppercase letter. This creates consistent, professional playbook output across logs, Tower/AWX, and terminal displays. Use ansible-lint --fix to auto-capitalize existing names. Combine with descriptive action verbs ("Install", "Configure", "Deploy", "Ensure") for clear, scannable playbook code.