XK0-006 Automation, Orchestration, and Scripting Practice Question
A team uses Ansible for configuration management. They want to ensure a service is running on all managed nodes. Which Ansible module should be used in the playbook?
⚠ Common exam trap
The trap is assuming systemd is always the right module because it is modern — but the question says 'all managed nodes,' implying heterogeneity, where the generic service module is safer.
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
✓
service
The Ansible service module is the generic, cross-platform module for managing services (started, stopped, enabled, restarted) and works across systemd, SysVinit, Upstart, and other init systems. It is the correct choice when the playbook must ensure a service is running on all managed nodes regardless of the underlying init system. Using service with state: started and enabled: yes is the idiomatic way to guarantee a service is running and persists across reboots.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
systemd
Why it's wrong here
The systemd module manages units on systemd hosts only; on nodes running another init system it fails or is unavailable, so it cannot ensure the service across all managed nodes. It is tempting because it is idempotent, and it would be correct in a purely systemd-managed estate.
- ✓
service
Why this is correct
The `service` module manages service state on managed nodes, directly satisfying the requirement to ensure a service is running across all hosts. It supports `state: started` and `enabled`, unlike `command` or `shell`, which execute arbitrary commands without idempotent service-state handling. This makes it the appropriate declarative choice for the playbook.
- ✗
command
Why it's wrong here
The command module runs an arbitrary binary without idempotence, so it reports changed on every run and cannot guarantee the service stays running. It is tempting because it executes systemctl directly, and it would be correct for one-off tasks where no desired-state enforcement is needed.
- ✗
shell
Why it's wrong here
The shell module invokes a shell and is not idempotent, so each run reports changed and cannot assert the service's desired state. It is tempting because piping systemctl output is convenient, and it would be correct for ad-hoc commands requiring shell features such as redirection or pipes.
Go deeper
Related to this question
Learn chapter
Installing Linux and Package Management
Key term
Init system
An init system is the first process started by the Linux kernel during boot that manages all other processes, services, and system initialization until shutdown.
Key term
systemd
systemd is a system and service manager for Linux operating systems that initializes and manages processes, services, and system resources after the kernel boots.
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.