In this lesson, you will learn:

  • what yamllint is
  • how to check your YAML files for issues using yamllint
  • how to install yamllint
  • yamllint's main configuration options.
You can find the scripts and code for this course within the Automating Python Code Quality repo.

What is YAML Lint?

As the name suggests, YAML lint allows us to check and validate our YAML files for issues, for example indentation issues.

Installing YAML Lint

To install YAML lint, simply perform a:

$ poetry add -D yamllint


yamllint can be run against a file or directory. If a directory is specified, yamllint will recursively check all of the files. Examples of each are shown below:

$ yamllint .
$ yamllint dir
$ yamllint myfile.yml

Therefore, let’s say we have the following file:

❯ cat 002_linting/004_yamllint_issues.yaml
  - vlan_id: 100
    vlan_name: SALES
    vlan_id: 200
    vlan_name: HR
Members Only Content
Want to Learn Network Automation?
Join our membership to access:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.