easyMultiple ChoiceObjective-mapped
XK0-006 Practice Question: A DevOps engineer needs to automate the…
A DevOps engineer needs to automate the deployment of a microservice using Ansible. The playbook should install the latest version of nginx on all web servers. Which Ansible module should be used in the playbook?
⚠ Common exam trap
Candidates often confuse the `service` module (for managing service state) with package installation modules, or they default to the `command` module out of habit, missing Ansible's dedicated package modules that ensure idempotency and cross-platform compatibility.
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
✓
apt: name=nginx state=latest
The `apt` module is the proper Ansible module for managing packages on Debian-based systems, and `state=latest` ensures the most recent version of nginx is installed. This aligns with the requirement to automate deployment using Ansible's declarative package management rather than imperative shell commands.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
service: name=nginx state=started
Why it's wrong here
This starts the service, but does not install nginx.
- ✗
command: apt install nginx
Why it's wrong here
The command module is not idempotent and not recommended for package management.
- ✓
apt: name=nginx state=latest
Why this is correct
The apt module with state=latest ensures the latest version is installed.
- ✗
yum: name=nginx state=latest
Why it's wrong here
yum is for RedHat-based systems, not Debian.
Go deeper
Related to this question
Learn chapter
Installing Linux and Package Management
Key term
apt
APT (Advanced Package Tool) is a command-line utility used in Debian-based Linux distributions to install, update, remove, and manage software packages from repositories.
Key term
Shell
A shell is a computer program that provides a user interface to access an operating system's services, typically by accepting text commands.
About these practice questions
One of 979 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.