A systems administrator is managing a large, autoscaling fleet of cloud-based virtual machines. The number of active servers fluctuates throughout the day based on demand. The administrator needs to use Ansible to consistently apply updates to all currently active servers. Which approach would be the most effective and maintainable solution for defining the target hosts?
Store the server hostnames in an Ansible Vault and reference the vault in the playbook.
Maintain a static INI inventory file and manually update it before each playbook run.
Use a dynamic inventory script to query the cloud provider's API.
Embed a list of all possible server IP addresses in the hosts line of the playbook.
The correct solution is to use a dynamic inventory. In a cloud environment where servers are created and destroyed automatically (autoscaling), a static inventory file quickly becomes outdated. A dynamic inventory uses a script or plugin to fetch the current list of active hosts from the cloud provider's API each time an Ansible command is run. This ensures that operations are always performed on the correct, up-to-date set of machines without manual intervention.
Manually updating a static inventory file is inefficient, prone to human error, and defeats the purpose of automation in a dynamic environment.
Hardcoding a list of hosts within a playbook is highly inflexible and unscalable, especially when the hosts change frequently.
Ansible Vault is a feature for encrypting and managing sensitive data, such as passwords or API keys, not for defining lists of target hosts.
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 a dynamic inventory script in Ansible?
Open an interactive chat with Bash
Why is a static inventory file unsuitable for autoscaling environments?
Open an interactive chat with Bash
What is the role of Ansible Vault, and why isn’t it suitable for host management?
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