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.
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.
Maintain a static INI inventory file and manually update it before each playbook run.
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...
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 .