XK0-006 Automation, Orchestration, and Scripting Practice Question
A Linux administrator is reviewing an Ansible playbook that manages a fleet of servers. The playbook must run a task only on hosts in the group webservers and must notify a handler when a configuration file changes. Which TWO of the following are valid Ansible constructs that the administrator should use? (Choose two.)
⚠ Common exam trap
The trap here is assuming that become or when are required for targeting and notification, when in fact hosts and notify are the keywords that directly implement those behaviors.
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
✓
notify: restart nginx
The hosts directive scopes the play to the webservers inventory group, and the notify keyword on a task causes a named handler to run when that task changes state. Together they ensure the play runs only on the intended hosts and that a service restart handler fires only when the configuration file is modified.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
serial: 1
Why it's wrong here
The serial keyword controls how many hosts are processed in each batch, which is useful for rolling updates. It does not restrict execution to the webservers group and does not trigger handlers on configuration changes, so it does not fulfill the two requirements described in the scenario.
- ✓
notify: restart nginx
Why this is correct
The notify keyword on a task triggers a handler by name when the task reports a changed state. Pairing it with a handler named restart nginx, defined in the handlers section, ensures the service is restarted only when the configuration file actually changes, which is the intended behavior.
- ✓
hosts: webservers
Why this is correct
The hosts directive at the play level specifies the target hosts for the play, and using the group name webservers limits execution to that inventory group. This is the standard way to scope a play to a subset of managed nodes, directly satisfying the requirement to run only on the webservers group.
- ✗
when: ansible_os_family == "Debian"
Why it's wrong here
The when clause conditionally runs a task based on a fact or variable. It is useful for OS-specific logic, but the scenario does not require filtering by OS family; it requires targeting a host group and notifying a handler on change, so this construct is not relevant to the stated requirements.
- ✗
become: yes
Why it's wrong here
The become directive enables privilege escalation, typically to root, for the task or play. While it is often needed for system administration, it does not address the requirement to target the webservers group or to notify a handler on configuration change, so it is not one of the constructs that satisfies the scenario.
Go deeper
Related to this question
Learn chapter
Linux Fundamentals and History
Key term
Linux
Linux is an open-source operating system that manages computer hardware and software, widely used in servers, desktops, and embedded systems.
Key term
Service
A service is a software component or system that performs a specific function and is available to be used by other programs or users over a network.
About these practice questions
Courseiva writes every XK0-006 question from scratch — 781 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 and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
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.