An administrator is writing an Ansible playbook to automate the management of a web server. The playbook needs to ensure the httpd service is started and enabled to run at boot. Which Ansible module is the most appropriate to accomplish this task in an idempotent manner?
The correct answer is ansible.builtin.service. This module is designed to control services on remote hosts in a platform-agnostic way. Using state: started ensures the service is running, and enabled: yes ensures it starts on boot. These actions are idempotent, meaning Ansible will only apply changes if the service is not already in the desired state.
ansible.builtin.package is incorrect because it is used for managing software packages (installing, removing, updating), not for controlling their running state.
ansible.builtin.command is incorrect because, while it could be used to run a command like systemctl start httpd, it is not idempotent by default. It would attempt to start the service every time the playbook runs, which is inefficient and not the best practice.
ansible.builtin.file is incorrect as it is used to manage files, directories, and symlinks, such as setting permissions or creating/deleting them, not managing service states.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does it mean for an Ansible module to be idempotent?
Open an interactive chat with Bash
How is `ansible.builtin.service` different from `ansible.builtin.command`?
Open an interactive chat with Bash
What happens if you use `ansible.builtin.package` instead of `ansible.builtin.service` in this scenario?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .