Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 712 Bytes

key_order.md

File metadata and controls

29 lines (22 loc) · 712 Bytes

key-order

This rule recommends reordering key names in ansible content to make code easier to maintain and less prone to errors.

Here are some examples of common ordering checks done for tasks and handlers:

  • name must always be the first key for plays, tasks and handlers
  • action should be the second key, just after name
  • when present, the block key must be the last, avoid accidental indentation bugs moving keys between block and the last task within the block.

Problematic code

---
- hosts: localhost
  name: This is a playbook # <-- name key should be the first one
  tasks: []

Correct code

---
- name: This is a playbook
  hosts: localhost
  tasks: []