# YAML File check

**URL:** <https://forum.ansible.com/t/yaml-file-check/37546>\
**Category:** Ansible Developer\
**Created:** [January 12, 2023, 6:59am UTC](https://forum.ansible.com/t/yaml-file-check/37546 "2023-01-12T06:59:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asad](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@Asad](https://forum.ansible.com/u/Asad)\
**Post date:** [January 12, 2023, 6:59am UTC](https://forum.ansible.com/t/yaml-file-check/37546/1 "2023-01-12T06:59:46Z")

</div>

Hi All ,

Is there any good tool or web link to verify the yaml file .

Thanks,

---

<div class="post-metadata">

**Author:** ![Didier\_BOURRIAUD](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@Didier\_BOURRIAUD](https://forum.ansible.com/u/Didier_BOURRIAUD)\
**Post date:** [January 12, 2023, 9:06am UTC](https://forum.ansible.com/t/yaml-file-check/37546/2 "2023-01-12T09:06:46Z")

</div>

Hi Asad Hasan,

Personally, I use YamlLint from the “sdesbure/yamllint” Docker Image → [https://hub.docker.com/r/sdesbure/yamllint](https://hub.docker.com/r/sdesbure/yamllint)

I made this alias in my BashRc to mount local path to /yaml in the container and launch it in every path: alias yamllint=‘eval docker run -it --rm -v ${PWD}:/yaml sdesbure/yamllint yamllint’

You can then write your own rules in a .yamllint file to override defaults. Rules documentation are here : [https://yamllint.readthedocs.io/en/stable/rules.html](https://yamllint.readthedocs.io/en/stable/rules.html)

I setup the rules like this :

```auto
---
extends: "default"

rules:
  line-length: "disable"
  indentation:
    indent-sequences: no
  comments:
    require-starting-space: yes
    min-spaces-from-content: 2
  comments-indentation: "disable"
  quoted-strings:
    quote-type: "double"
  truthy:
    allowed-values:
    - "yes"
    - "no"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 12, 2023, 4:49pm UTC](https://forum.ansible.com/t/yaml-file-check/37546/3 "2023-01-12T16:49:23Z")

</div>

Most yaml linters will only tell you if the file is valid YAML and to theri opinion/spec, which is not always what Ansible uses, we relly on pyyaml which is following YAML 1.1 spec.

You have ansible-lint as a general tools, but if you just want a quick test for playbooks `ansbile-playbook --syntax-check playbook.yml `, for vars files i would use `ansbile -m include_vars ....`, for roles `ansbile -m import_role ...`
