Linting with yamllint

Document Control

TODO:

  • Overall structure.
  • Initial draft complete
  • Testing
  • Ready

User Story: Yamllint

As a: Ansible developer

I want to: check for syntax validity, trailing spaces, indentation, etc.

So that: write consistent, valid YAML.

Installation

Install yamllint using pip
pip3 install --upgrade --user yamllint
# Lint specific file
yamllint site.yml

# All files in current directory (recursive)
yamllint .

Configuration

You configure the various rules that trigger warnings or errors in a .yamllint file. For example:

.yamlint
---
extends: default

rules:
  braces:
    max-spaces-inside: 1
    level: error
  brackets:
    max-spaces-inside: 1
    level: error
  line-length:
    max: 120
    level: warning
  truthy:
    level: warning

Last update: 2020-01-29