Courseiva
Automation, Orchestration, and ScriptinghardMultiple ChoiceObjective-mapped

XK0-006 Automation, Orchestration, and Scripting Practice Question

A DevOps team is using Ansible to manage configuration of web servers. They need to ensure that the Apache service is running and enabled at boot on all servers in the 'webservers' group. Which playbook task accomplishes this?

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

- name: Ensure Apache is running service: name: httpd state: started enabled: yes

The Ansible service module can manage services; the 'enabled' and 'state' parameters control boot status and running state.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • - name: Ensure Apache is running systemd: name: httpd state: started enabled: yes

    Why it's wrong here

    The systemd module is used for systemd systems, but the service module is more generic and recommended for CompTIA Linux+. However, systemd is also correct; but the question expects the service module as the standard Ansible module.

  • - name: Ensure Apache is running shell: systemctl start httpd && systemctl enable httpd

    Why it's wrong here

    Using shell module is not idempotent and discouraged when a module exists.

  • - name: Ensure Apache is running command: systemctl enable --now httpd

    Why it's wrong here

    Using command module is not idempotent and not best practice; Ansible modules should be used.

  • - name: Ensure Apache is running service: name: httpd state: started enabled: yes

    Why this is correct

    Correct. The service module with state=started and enabled=yes ensures the service is running and enabled.

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 →

How Courseiva writes practice questions · Editorial policy

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.