Hi All ,
Is there any good tool or web link to verify the yaml file .
Thanks,
Hi All ,
Is there any good tool or web link to verify the yaml file .
Thanks,
Hi Asad Hasan,
Personally, I use YamlLint from the “sdesbure/yamllint” Docker Image → 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
I setup the rules like this :
---
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"
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 ...