Skip to content

Validate / lint yaml

yamllint

  • GitHub
  • Docs
    • Configuration
      • a file named .yamllint, .yamllint.yaml, or .yamllint.yml in the current working directory, or a parent directory (the search for this file is terminated at the user’s home or filesystem root)
      • a filename referenced by $YAMLLINT_CONFIG_FILE, if set
      • ~/.config/yamllint/config, if present
    • Disable with comments
  • Megalinter integration
    • Megalinter looks for a .yamllint.yml config file
  • pre-commit hook

Install:

apt install yamllint

Usage:

yamllint hiera/local1.yaml

v8r

A command-line JSON, YAML and TOML validator that uses Schema Store to detect a suitable schema for your input files based on the filename.

Usage:

npx v8r ...

Other linters

or

cat hiera/local1.yaml| shyaml get-values

cat .gitlab-ci.yml| ysh

Sort yaml

https://github.com/ddebin/yaml-sort

npm install -g yaml-sort

Yaml formaters

Prettier