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...
IT & Cybersecurity Package Join Premium for Full Access