mediumMultiple ChoiceObjective-mapped
XK0-006 An Ansible playbook fails with a syntax error Practice Question
An Ansible playbook fails with a syntax error. Which command validates the playbook syntax without running it?
⚠ Common exam trap
Many candidates confuse `--syntax-check` with `--check` (dry run) or assume `ansible-lint` is the syntax validator, but `--syntax-check` is the only command that validates syntax without any execution.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
ansible-playbook --syntax-check
The `--syntax-check` flag is a built-in option of `ansible-playbook` that parses the YAML file and validates its syntax without executing any tasks. This is the correct tool for catching syntax errors in a playbook before running it.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ansible-lint playbook.yml
Why it's wrong here
ansible-lint is a separate utility that checks for best practices and style, but it is not built into ansible-playbook and may not catch all syntax errors.
- ✗
ansible-playbook --check
Why it's wrong here
--check runs the playbook in 'check mode' to simulate changes, but does not validate syntax; it requires a connection to hosts.
- ✗
ansible-playbook --validate
Why it's wrong here
There is no --validate option in ansible-playbook.
- ✓
ansible-playbook --syntax-check
Why this is correct
This command parses the playbook and reports syntax errors without executing any tasks.
Go deeper
Related to this question
About these practice questions
Courseiva writes every XK0-006 question from scratch — 979 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.