YAML File check

28 views
Skip to first unread message

Asad Hasan

unread,
Jan 12, 2023, 1:59:46 AM1/12/23
to Ansible Development
Hi All ,

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

Thanks,

Didier BOURRIAUD

unread,
Jan 12, 2023, 4:07:17 AM1/12/23
to Asad Hasan, Ansible Development
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"

Hope you'll find your happiness !

Best regards,
--

Kosmos

Didier BOURRIAUD
Expert Technique
Tél. : +33 (0) 6.84.18.76.21 - 8 rue Kervégan 44000 Nantes - France

Twitter Linkedin Youtube www.kosmos-education.com
Qualiopi


--
You received this message because you are subscribed to the Google Groups "Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/3352efc5-59d6-4304-8624-afe8346bff10n%40googlegroups.com.

Brian Coca

unread,
Jan 12, 2023, 11:51:28 AM1/12/23
to Didier BOURRIAUD, Asad Hasan, Ansible Development
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 ...`

--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages