A systems administrator needs to perform a quick, one-time task to restart all servers in the [webservers] group defined in their inventory.ini file. The administrator does not need to save the task for later reuse. Which of the following commands correctly demonstrates an ad hoc approach using Ansible?
The correct answer uses the ansible command, which is designed for running single, non-reusable tasks, also known as ad hoc commands. The command ansible webservers -i inventory.ini -m reboot correctly targets the webservers host group, specifies the inventory file with -i, and uses the reboot module (-m reboot) to perform the restart.
The ansible-playbook command is incorrect because it is used to run playbooks (YAML files), which are meant for complex, repeatable automation, not for simple, one-off commands.
The ansible-galaxy command is incorrect as it is used to manage Ansible roles and collections (e.g., downloading them from a repository), not to execute tasks on managed hosts.
The ansible-vault command is incorrect because its purpose is to create and manage encrypted files for storing sensitive data, not to run commands.
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 is an ad hoc command in Ansible?
Open an interactive chat with Bash
What is the difference between an Ansible ad hoc command and a playbook?
Open an interactive chat with Bash
What is the function of the `-m` flag in an Ansible command?
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