Syntax Check
Ansible has a built-in utility to validate the syntax of your yaml files. Add --syntax-check to your ansible-playbook execution and the yaml parser will validate your file formatting without running tasks.
| |
If your playbook passes the check, the output is rather boring.
| |
The interpreter for --syntax-check strictly cares about whether it can interpret raw yaml and cares nothing for best practices like naming all your tasks, deprecated modules, idempotency, missing metadata, or spacing in your variable invocations. However, if you were to accidentally forget to put a colon after your tasks declaration, the syntax checking engine would notice, and try to identify a place near where the colon is missing.
| |
The syntax check is safe to use for any of your sandbox, development, or production environments because it will never actually run your tasks. Notice the example above doesn’t even reference an inventory to run the check, so no credentials are needed, either.