What does ansible-playbook --syntax-check do, and why run it first?
It parses the playbook and reports YAML and Ansible syntax errors without connecting to any host or running any task.
ansible-playbook --syntax-check playbook-basic/site.yml catches the cheap mistakes before they can do anything: a tab instead of spaces, a mis-indented key, an unknown play keyword, a missing colon. It doesn't contact hosts, so it is fast and safe to run anywhere, including as the first step of a CI pipeline on every commit.
What it does not find: wrong module arguments' values, missing files referenced by src:, unreachable hosts, or tasks that would do the wrong thing. For a dry run against real hosts there is the separate check mode, ansible-playbook --check site.yml, which asks the modules to report what they would change without changing it.
Go deeper:
ansible-playbook command reference (official docs) —
--syntax-checkand related flags.Validating tasks: check mode and diff mode (official docs) — the dry run that goes one step further.