XK0-006 Automation, Orchestration, and Scripting Practice Question
A system administrator needs to update a configuration file on multiple servers using Ansible. The playbook must ensure the line 'MaxAuthTries 3' is present in /etc/ssh/sshd_config. Which Ansible module is most appropriate?
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
✓
lineinfile
The lineinfile module ensures a specific line is present in a file, ideal for configuration management.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
template
Why it's wrong here
Template renders a whole file from a Jinja2 source, replacing sshd_config entirely and discarding unmanaged directives; lineinfile edits in place. Template is tempting when the entire configuration must be generated dynamically from variables, which this single-line requirement does not demand.
- ✗
shell
Why it's wrong here
Shell executes arbitrary commands without idempotence, so reruns may duplicate the line and report changed every time; lineinfile checks and only inserts when absent. Shell is tempting for quick ad-hoc edits, but it is the correct choice when no dedicated module exists for the task.
- ✗
copy
Why it's wrong here
The copy module overwrites the whole file from source, so any other sshd_config directives are lost; lineinfile preserves existing content while ensuring the specified line. Copy is tempting when distributing a complete, centrally managed configuration file, where full replacement is intended.
- ✓
lineinfile
Why this is correct
lineinfile manages individual lines within an existing file, adding 'MaxAuthTries 3' if absent and matching by regexp. This satisfies the requirement to ensure a specific configuration line is present across multiple servers without rewriting the whole file.
Go deeper
Related to this question
About these practice questions
This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.