A Linux administrator needs to quickly verify that the nginx service is running on all web servers defined in their Ansible inventory file. The administrator does not want to write a full playbook for this simple, one-time check. Which of the following Ansible components is the most efficient for this task?
The correct answer is an ad hoc command. Ansible ad hoc commands are used to execute a single, simple task across multiple hosts directly from the command line without the need for a playbook file. This is ideal for quick checks or simple operations, such as verifying a service status. For this scenario, a command like ansible webservers -m ansible.builtin.service -a "name=nginx state=started" would be used.
An Ansible playbook is designed for more complex, multi-step, and reusable automation tasks that are saved in a YAML file for version control and repeated execution; it would be inefficient for a simple, one-time check.
Ansible Facts are pieces of information (variables) gathered about the managed nodes, such as the operating system or IP address. They are used within playbooks or commands to make decisions but are not a method for executing a task themselves.
An Ansible Collection is a distribution format for packaging and sharing Ansible content, including roles, modules, and plugins, but it is not a direct method for executing a command.
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 are Ansible ad hoc commands?
Open an interactive chat with Bash
What is the difference between an Ansible ad hoc command and an Ansible playbook?
Open an interactive chat with Bash
What is the purpose of the `ansible.builtin.service` module?
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